This repository has no description
0

Configure Feed

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

core / spindle / engines / microvm / models_test.go
1.2 kB 43 lines
1//go:build linux 2 3package microvm 4 5import ( 6 "slices" 7 "testing" 8) 9 10func TestWorkflowCaches(t *testing.T) { 11 urls, keys, err := workflowCaches(map[string]string{ 12 "https://hydra.nixos.org/": "hydra.nixos.org-1:CNHJZBh9K4tP3EKF6FkkgeVYsS3ohTl+oS0Qa8bezVs=", 13 "https://cache.garnix.io/": "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=", 14 "https://unsigned.example/": "", 15 }) 16 if err != nil { 17 t.Fatal(err) 18 } 19 20 wantURLs := []string{ 21 "https://cache.garnix.io/", 22 "https://hydra.nixos.org/", 23 "https://unsigned.example/", 24 } 25 if !slices.Equal(urls, wantURLs) { 26 t.Fatalf("urls: got %v, want %v", urls, wantURLs) 27 } 28 wantKeys := []string{ 29 "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=", 30 "hydra.nixos.org-1:CNHJZBh9K4tP3EKF6FkkgeVYsS3ohTl+oS0Qa8bezVs=", 31 } 32 if !slices.Equal(keys, wantKeys) { 33 t.Fatalf("keys: got %v, want %v", keys, wantKeys) 34 } 35} 36 37func TestWorkflowCachesRejectsBadURLs(t *testing.T) { 38 for _, bad := range []string{"ftp://cache.example/", "not a url"} { 39 if _, _, err := workflowCaches(map[string]string{bad: ""}); err == nil { 40 t.Errorf("workflowCaches(%q): expected error, got nil", bad) 41 } 42 } 43}