| 1 | package config |
| 2 | |
| 3 | import ( |
| 4 | "strings" |
| 5 | "testing" |
| 6 | |
| 7 | "github.com/BurntSushi/toml" |
| 8 | ) |
| 9 | |
| 10 | func TestRenderTOMLPersistsOfflineEnvironment(t *testing.T) { |
| 11 | cfg := Default() |
| 12 | cfg.Environment.Offline = true |
| 13 | |
| 14 | for _, scope := range []RenderScope{RenderScopeFull, RenderScopeUser, RenderScopeProject} { |
| 15 | rendered := RenderTOMLForScope(cfg, scope) |
| 16 | if !strings.Contains(rendered, "offline = true") { |
| 17 | t.Fatalf("%s-scope render missing offline declaration", scope) |
| 18 | } |
| 19 | |
| 20 | back := Default() |
| 21 | if _, err := toml.Decode(rendered, back); err != nil { |
| 22 | t.Fatalf("%s-scope round-trip decode: %v", scope, err) |
| 23 | } |
| 24 | if !back.Environment.Offline { |
| 25 | t.Fatalf("%s-scope round-trip lost offline declaration", scope) |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 |