-
Notifications
You must be signed in to change notification settings - Fork 19
/
triton_test.go
41 lines (36 loc) · 932 Bytes
/
triton_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//
// Copyright 2020 Joyent, Inc.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
package triton_test
import (
"os"
"testing"
triton "github.com/joyent/triton-go/v2"
)
func TestGetEnv(t *testing.T) {
tests := []struct {
name string
varname string
input string
value string
}{
{"Triton", "TRITON_NAME", "NAME", "good"},
{"SDC", "SDC_NAME", "NAME", "good"},
{"unrelated", "BAD_NAME", "NAME", ""},
{"missing", "", "NAME", ""},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
os.Setenv(test.varname, test.value)
defer os.Unsetenv(test.varname)
if val := triton.GetEnv(test.input); val != test.value {
t.Errorf("expected %s env var to be '%s': got '%s'",
test.varname, test.value, val)
}
})
}
}