-
Notifications
You must be signed in to change notification settings - Fork 10
/
config_test.go
46 lines (42 loc) · 893 Bytes
/
config_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
42
43
44
45
46
package main
import (
"encoding/json"
"testing"
)
var cfg = `
{
"project":"demo",
"zone" : "zone",
"region" : "region",
"bucket":"bucket",
"state": "state",
"env" : {
"FOO" : "BAR"
}
}
`
func TestConfig(t *testing.T) {
var c Config
if err := json.Unmarshal([]byte(cfg), &c); err != nil {
t.Fatal(err)
}
if err := c.Validate(); err != nil {
t.Fatal(err)
}
if got, want := c.EnvironmentVars["FOO"], "BAR"; got != want {
t.Logf("got [%v] want [%v]", got, want)
}
if got, want := c.LastMigrationObjectName, "state"; got != want {
t.Logf("got [%v] want [%v]", got, want)
}
if got, want := c.shellEnv()[3], "FOO=BAR"; got != want {
t.Logf("got [%v] want [%v]", got, want)
}
}
func TestTryToLoadConfig(t *testing.T) {
c, err := TryToLoadConfig("bogus")
if err == nil {
t.Error("should return error about non existing bogus folder/file")
}
t.Log(c, err)
}