github.com/SupersunnySea/draft@v0.16.0/pkg/draft/pack/repo/repo_test.go (about) 1 package repo 2 3 import ( 4 "path/filepath" 5 "testing" 6 ) 7 8 func TestPack(t *testing.T) { 9 r := Repository{ 10 Name: "testRepo1", 11 Dir: filepath.Join("testdata", "packs", "github.com", "testOrg1", "testRepo1"), 12 } 13 14 targetPack := "testpack2" 15 expected := filepath.Join("testdata", "packs", "github.com", "testOrg1", "testRepo1", "packs", "testpack2") 16 pack, err := r.Pack(targetPack) 17 if err != nil { 18 t.Fatal(err) 19 } 20 if pack != expected { 21 t.Errorf("Expected pack %s, got %s", expected, pack) 22 } 23 24 } 25 26 func TestPackNotFound(t *testing.T) { 27 r := Repository{ 28 Name: "testRepo1", 29 Dir: filepath.Join("testdata", "packs", "github.com", "testOrg1", "testRepo1"), 30 } 31 targetPack := "nopack" 32 if _, err := r.Pack(targetPack); err == nil { 33 t.Error("Expected error, got no error") 34 } 35 }