(t *testing.T)
| 398 | } |
| 399 | |
| 400 | func TestDefault(t *testing.T) { |
| 401 | path := filepath.Join(t.TempDir()) |
| 402 | cfg := DefaultConfig() |
| 403 | inBytes := cfg.Root.Bytes() |
| 404 | if _, err := hujson.Parse(inBytes); err != nil { |
| 405 | t.Fatalf("default config JSON is invalid: %v\n%s", err, inBytes) |
| 406 | } |
| 407 | err := cfg.Root.SaveTo(path) |
| 408 | if err != nil { |
| 409 | t.Fatal("got save error:", err) |
| 410 | } |
| 411 | out, err := Open(filepath.Join(path, configfile.DefaultName)) |
| 412 | if err != nil { |
| 413 | t.Fatal("got load error:", err) |
| 414 | } |
| 415 | if diff := cmp.Diff( |
| 416 | cfg, |
| 417 | out, |
| 418 | cmpopts.IgnoreUnexported(configfile.ConfigFile{}, configfile.PackagesMutator{}, Config{}), |
| 419 | cmpopts.IgnoreFields(configfile.ConfigFile{}, "AbsRootPath"), |
| 420 | ); diff != "" { |
| 421 | t.Errorf("configs not equal (-in +out):\n%s", diff) |
| 422 | } |
| 423 | |
| 424 | outBytes := out.Root.Bytes() |
| 425 | if _, err := hujson.Parse(outBytes); err != nil { |
| 426 | t.Fatalf("loaded default config JSON is invalid: %v\n%s", err, outBytes) |
| 427 | } |
| 428 | if string(inBytes) != string(outBytes) { |
| 429 | t.Errorf("got different JSON after load/save/load:\ninput:\n%s\noutput:\n%s", inBytes, outBytes) |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | func TestOSExpandIfPossible(t *testing.T) { |
| 434 | tests := []struct { |
nothing calls this directly
no test coverage detected