• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mongodb / mongodb-atlas-cli / 16809123642

07 Aug 2025 03:39PM UTC coverage: 64.742% (-0.06%) from 64.802%
16809123642

push

github

web-flow
refactor: move env vars from tests into one place (#4103)

0 of 89 new or added lines in 3 files covered. (0.0%)

2 existing lines in 1 file now uncovered.

26436 of 40833 relevant lines covered (64.74%)

0.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/test/internal/env.go
1
// Copyright 2025 MongoDB Inc
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15
package internal
16

17
import (
18
        "errors"
19
        "fmt"
20
        "os"
21
        "strings"
22
)
23

24
type TestMode string
25

26
const (
27
        TestModeLive   TestMode = "live"   // run tests against a live Atlas instance (this do not replay or record snapshots)
28
        TestModeRecord TestMode = "record" // record snapshots
29
        TestModeReplay TestMode = "replay" // replay snapshots
30
)
31

NEW
32
func TestRunMode() (TestMode, error) {
×
NEW
33
        mode := os.Getenv("TEST_MODE")
×
NEW
34
        if mode == "" || strings.EqualFold(mode, "live") {
×
NEW
35
                return TestModeLive, nil
×
NEW
36
        }
×
37

NEW
38
        if strings.EqualFold(mode, "record") {
×
NEW
39
                return TestModeRecord, nil
×
NEW
40
        }
×
41

NEW
42
        if strings.EqualFold(mode, "replay") {
×
NEW
43
                return TestModeReplay, nil
×
NEW
44
        }
×
45

NEW
46
        return TestModeLive, fmt.Errorf("invalid value for environment variable TEST_MODE: %s, expected 'live', 'record' or 'replay'", mode)
×
47
}
48

NEW
49
func SkipCleanup() bool {
×
NEW
50
        mode, err := TestRunMode()
×
NEW
51
        if err != nil {
×
NEW
52
                return false
×
NEW
53
        }
×
54

NEW
55
        if mode == TestModeLive {
×
NEW
56
                return false
×
NEW
57
        }
×
58

NEW
59
        return true
×
60
}
61

NEW
62
func IdentityProviderID() (string, error) {
×
NEW
63
        idpID, ok := os.LookupEnv("IDENTITY_PROVIDER_ID")
×
NEW
64
        if !ok || idpID == "" {
×
NEW
65
                return "", errors.New("environment variable is missing: IDENTITY_PROVIDER_ID")
×
NEW
66
        }
×
67

NEW
68
        return idpID, nil
×
69
}
70

NEW
71
func FlexInstanceName() (string, error) {
×
NEW
72
        instanceName, ok := os.LookupEnv("E2E_FLEX_INSTANCE_NAME")
×
NEW
73
        if !ok || instanceName == "" {
×
NEW
74
                return "", errors.New("environment variable is missing: E2E_FLEX_INSTANCE_NAME")
×
NEW
75
        }
×
76

NEW
77
        return instanceName, nil
×
78
}
79

NEW
80
func CloudRoleID() (string, error) {
×
NEW
81
        roleID, ok := os.LookupEnv("E2E_CLOUD_ROLE_ID")
×
NEW
82
        if !ok || roleID == "" {
×
NEW
83
                return "", errors.New("environment variable is missing: E2E_CLOUD_ROLE_ID")
×
NEW
84
        }
×
85

NEW
86
        return roleID, nil
×
87
}
88

NEW
89
func TestBucketName() (string, error) {
×
NEW
90
        bucketName, ok := os.LookupEnv("E2E_TEST_BUCKET")
×
NEW
91
        if !ok || bucketName == "" {
×
NEW
92
                return "", errors.New("environment variable is missing: E2E_TEST_BUCKET")
×
NEW
93
        }
×
94

NEW
95
        return bucketName, nil
×
96
}
97

NEW
98
func GCPCredentials() (string, error) {
×
NEW
99
        credentials, ok := os.LookupEnv("GCP_CREDENTIALS")
×
NEW
100
        if !ok || credentials == "" {
×
NEW
101
                return "", errors.New("environment variable is missing: GCP_CREDENTIALS")
×
NEW
102
        }
×
103

NEW
104
        return credentials, nil
×
105
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc