package artifactregistry import ( "context" "fmt" "path/filepath" "testing" "google.golang.org/api/iterator" ) var ( warehouseRepo = "warehouse" platformInfraProject = "ret-edge-pltf-infra" ) func TestNewF8nGARClient(t *testing.T) { garClient, err := NewArtifactRegistry(context.Background()) if err != nil { t.Error(err) t.Fail() } garClient.Close() } func TestListTags(t *testing.T) { garClient, err := NewArtifactRegistry(context.Background()) if err != nil { t.Error(err) t.Fail() } it, err := garClient.ListTags("us-east1", platformInfraProject, warehouseRepo, "store") if err != nil { t.Error(err) t.Fail() } for { listResp, err := it.Next() if err == iterator.Done { break } tag := filepath.Base(listResp.Name) digest := filepath.Base(listResp.Version) fmt.Println(tag) fmt.Println(digest) } garClient.Close() } func TestGetVersion(t *testing.T) { garClient, err := NewArtifactRegistry(context.Background()) if err != nil { t.Error(err) t.Fail() } v, err := garClient.GetVersion("us-east1", platformInfraProject, warehouseRepo, "store", "sha256:ed3b5246c97f4d6225eaaba5159c46332fe8f0e991f9799cf896d6aa198b24c4") if err != nil { t.Error(err) t.Fail() } tags := v.GetRelatedTags() for _, t := range tags { fmt.Println(t.Name) fmt.Println(t.Version) } // fmt.Printf("%+v\n", v) } func TestGetTag(t *testing.T) { garClient, err := NewArtifactRegistry(context.Background()) if err != nil { t.Error(err) t.Fail() } v, err := garClient.GetTag("us-east1", platformInfraProject, warehouseRepo, "store", "0.13") if err != nil { t.Error(err) t.Fail() } fmt.Printf("%+v\n", v) }