MCPcopy Index your code
hub / github.com/jetify-com/devbox / TestDefault

Function TestDefault

internal/devconfig/config_test.go:400–431  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

398}
399
400func 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
433func TestOSExpandIfPossible(t *testing.T) {
434 tests := []struct {

Callers

nothing calls this directly

Calls 4

DefaultConfigFunction · 0.85
BytesMethod · 0.80
SaveToMethod · 0.80
OpenFunction · 0.70

Tested by

no test coverage detected