MCPcopy
hub / github.com/esm-dev/esm.sh / TestEncodeBuildArgs

Function TestEncodeBuildArgs

server/build_args_test.go:9–52  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestEncodeBuildArgs(t *testing.T) {
10 conditions := []string{"react-server"}
11 buildArgsString := encodeBuildArgs(
12 BuildArgs{
13 Alias: map[string]string{"a": "b"},
14 Deps: map[string]string{
15 "c": "1.0.0",
16 "d": "1.0.0",
17 "e": "1.0.0",
18 },
19 External: *set.NewReadOnly("baz", "bar"),
20 Conditions: conditions,
21 ExternalRequire: true,
22 KeepNames: true,
23 IgnoreAnnotations: true,
24 },
25 false,
26 )
27 args, err := decodeBuildArgs(buildArgsString)
28 if err != nil {
29 t.Fatal(err)
30 }
31 if len(args.Alias) != 1 || args.Alias["a"] != "b" {
32 t.Fatal("invalid alias")
33 }
34 if len(args.Deps) != 3 {
35 t.Fatal("invalid deps")
36 }
37 if args.External.Len() != 2 {
38 t.Fatal("invalid external")
39 }
40 if len(args.Conditions) != 1 || args.Conditions[0] != "react-server" {
41 t.Fatal("invalid conditions")
42 }
43 if !args.ExternalRequire {
44 t.Fatal("ignoreRequire should be true")
45 }
46 if !args.KeepNames {
47 t.Fatal("keepNames should be true")
48 }
49 if !args.IgnoreAnnotations {
50 t.Fatal("ignoreAnnotations should be true")
51 }
52}

Callers

nothing calls this directly

Calls 3

encodeBuildArgsFunction · 0.85
decodeBuildArgsFunction · 0.85
LenMethod · 0.45

Tested by

no test coverage detected