MCPcopy Create free account
hub / github.com/jetify-com/devbox / TestParseStorePathFromInstallableOutput

Function TestParseStorePathFromInstallableOutput

internal/nix/store_test.go:9–58  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestParseStorePathFromInstallableOutput(t *testing.T) {
10 testCases := []struct {
11 name string
12 input string
13 expected map[string]bool
14 }{
15 {
16 name: "go-basic-nix-2-20-1",
17 // snipped the actual output for brevity. We mainly care about the first key in the JSON.
18 input: `{"/nix/store/fgkl3qk8p5hnd07b0dhzfky3ys5gxjmq-go-1.22.0":{"deriver":"/nix/store/clr3bm8njqysvyw4r4x4xmldhz4knrff-go-1.22.0.drv"}}`,
19 expected: map[string]bool{
20 "/nix/store/fgkl3qk8p5hnd07b0dhzfky3ys5gxjmq-go-1.22.0": true,
21 },
22 },
23 {
24 name: "go-basic-nix-2-20-1",
25 // snipped the actual output for brevity. We mainly care about the first key in the JSON.
26 input: `{"/nix/store/fgkl3qk8p5hnd07b0dhzfky3ys5gxjmq-go-1.22.0":null}`,
27 expected: map[string]bool{
28 "/nix/store/fgkl3qk8p5hnd07b0dhzfky3ys5gxjmq-go-1.22.0": false,
29 },
30 },
31 {
32 name: "go-basic-nix-2-17-0",
33 input: `[{"path":"/nix/store/fgkl3qk8p5hnd07b0dhzfky3ys5gxjmq-go-1.22.0"}]`,
34 expected: map[string]bool{
35 "/nix/store/fgkl3qk8p5hnd07b0dhzfky3ys5gxjmq-go-1.22.0": false,
36 },
37 },
38 {
39 name: "go-basic-nix-2-17-0",
40 input: `[{"path":"/nix/store/fgkl3qk8p5hnd07b0dhzfky3ys5gxjmq-go-1.22.0", "valid": true}]`,
41 expected: map[string]bool{
42 "/nix/store/fgkl3qk8p5hnd07b0dhzfky3ys5gxjmq-go-1.22.0": true,
43 },
44 },
45 }
46
47 for _, tc := range testCases {
48 t.Run(tc.name, func(t *testing.T) {
49 actual, err := parseStorePathFromInstallableOutput([]byte(tc.input))
50 if err != nil {
51 t.Errorf("Expected no error but got error: %s", err)
52 }
53 if !maps.Equal(tc.expected, actual) {
54 t.Errorf("Expected store path %v but got %v", tc.expected, actual)
55 }
56 })
57 }
58}

Callers

nothing calls this directly

Calls 2

RunMethod · 0.65

Tested by

no test coverage detected