This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

core / spindle / engines / microvm / cid_test.go
1.1 kB 45 lines
1package microvm 2 3import ( 4 "testing" 5) 6 7func TestBuildConfigKeyScopesByRepo(t *testing.T) { 8 spec := ImageSpec{BaseConfigHash: "deadbeef"} 9 cfg := manifestConfig{Dependencies: []string{"nodejs"}} 10 11 a, err := buildConfigKey(spec, cfg, "did:plc:aaa") 12 if err != nil { 13 t.Fatal(err) 14 } 15 b, err := buildConfigKey(spec, cfg, "did:plc:bbb") 16 if err != nil { 17 t.Fatal(err) 18 } 19 if a == b { 20 t.Errorf("same config in different repos produced the same key %q", a) 21 } 22 23 again, err := buildConfigKey(spec, cfg, "did:plc:aaa") 24 if err != nil { 25 t.Fatal(err) 26 } 27 if a != again { 28 t.Errorf("key not deterministic: %q vs %q", a, again) 29 } 30} 31 32func TestCgroupResourcesCPUQuota(t *testing.T) { 33 r := cgroupResources(CgroupLimits{CPUQuotaPercent: 200}) 34 if r.CPU == nil { 35 t.Fatal("cpu quota should produce a cpu controller config") 36 } 37 if got := string(r.CPU.Max); got != "200000 100000" { 38 t.Errorf("cpu.max = %q, want %q", got, "200000 100000") 39 } 40 41 r = cgroupResources(CgroupLimits{}) 42 if r.CPU != nil { 43 t.Errorf("no quota should leave cpu unlimited, got %v", r.CPU) 44 } 45}