Monorepo for Tangled tangled.org
5

Configure Feed

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

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