(t *testing.T)
| 140 | } |
| 141 | |
| 142 | func Test_SaveConfig_preservesKeyOrder(t *testing.T) { |
| 143 | original := "profile abc123\ncache-size 100MB\n" |
| 144 | path := writeConfigFile(t, original) |
| 145 | |
| 146 | str := "200MB" |
| 147 | profile := &testListEntry{vals: []string{"abc123"}} |
| 148 | c := map[string]ConfigEntry{ |
| 149 | "cache-size": ConfigValue{Value: &str, Default: "0"}, |
| 150 | "profile": profile, |
| 151 | } |
| 152 | |
| 153 | if err := (ConfigFileStorer{File: path}).SaveConfig(c); err != nil { |
| 154 | t.Fatal(err) |
| 155 | } |
| 156 | |
| 157 | got := readFile(t, path) |
| 158 | profileIdx := strings.Index(got, "profile") |
| 159 | cacheIdx := strings.Index(got, "cache-size") |
| 160 | if profileIdx == -1 || cacheIdx == -1 { |
| 161 | t.Fatalf("missing keys in output:\n%s", got) |
| 162 | } |
| 163 | // profile appeared first in original file, must stay first |
| 164 | if profileIdx > cacheIdx { |
| 165 | t.Errorf("expected profile before cache-size (original order):\n%s", got) |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | func Test_SaveConfig_newKeysAppendedAlphabetically(t *testing.T) { |
| 170 | // File only has "profile"; "cache-size" and "debug" are new |
nothing calls this directly
no test coverage detected
searching dependent graphs…