...
1 package artifactregistry
2
3 import (
4 "context"
5 "fmt"
6 "path/filepath"
7 "testing"
8
9 "google.golang.org/api/iterator"
10 )
11
12 var (
13 warehouseRepo = "warehouse"
14 platformInfraProject = "ret-edge-pltf-infra"
15 )
16
17 func TestNewF8nGARClient(t *testing.T) {
18 garClient, err := NewArtifactRegistry(context.Background())
19 if err != nil {
20 t.Error(err)
21 t.Fail()
22 }
23
24 garClient.Close()
25 }
26
27 func TestListTags(t *testing.T) {
28 garClient, err := NewArtifactRegistry(context.Background())
29 if err != nil {
30 t.Error(err)
31 t.Fail()
32 }
33
34 it, err := garClient.ListTags("us-east1", platformInfraProject, warehouseRepo, "store")
35 if err != nil {
36 t.Error(err)
37 t.Fail()
38 }
39
40 for {
41 listResp, err := it.Next()
42 if err == iterator.Done {
43 break
44 }
45
46 tag := filepath.Base(listResp.Name)
47 digest := filepath.Base(listResp.Version)
48 fmt.Println(tag)
49 fmt.Println(digest)
50 }
51
52 garClient.Close()
53 }
54
55 func TestGetVersion(t *testing.T) {
56 garClient, err := NewArtifactRegistry(context.Background())
57 if err != nil {
58 t.Error(err)
59 t.Fail()
60 }
61
62 v, err := garClient.GetVersion("us-east1", platformInfraProject, warehouseRepo, "store", "sha256:ed3b5246c97f4d6225eaaba5159c46332fe8f0e991f9799cf896d6aa198b24c4")
63 if err != nil {
64 t.Error(err)
65 t.Fail()
66 }
67 tags := v.GetRelatedTags()
68 for _, t := range tags {
69 fmt.Println(t.Name)
70 fmt.Println(t.Version)
71 }
72
73
74 }
75
76 func TestGetTag(t *testing.T) {
77 garClient, err := NewArtifactRegistry(context.Background())
78 if err != nil {
79 t.Error(err)
80 t.Fail()
81 }
82
83 v, err := garClient.GetTag("us-east1", platformInfraProject, warehouseRepo, "store", "0.13")
84 if err != nil {
85 t.Error(err)
86 t.Fail()
87 }
88
89 fmt.Printf("%+v\n", v)
90 }
91
View as plain text