|
| 1 | +package smoketest |
| 2 | + |
| 3 | +import ( |
| 4 | +//meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 5 | +"k8s.io/client-go/kubernetes" |
| 6 | +"os/exec" |
| 7 | +"strings" |
| 8 | +"testing" |
| 9 | +) |
| 10 | + |
| 11 | +func TestShowCluster(t *testing.T) { |
| 12 | +var clientset *kubernetes.Clientset |
| 13 | +var cluster string |
| 14 | + |
| 15 | +// t.Fatal("not implemented") |
| 16 | +t.Run("setup", func(t *testing.T) { |
| 17 | +t.Log("some setup code") |
| 18 | +clientset, _ = SetupKube() |
| 19 | +if clientset == nil { |
| 20 | +t.Error("clientset is nil") |
| 21 | +} |
| 22 | +}) |
| 23 | + |
| 24 | +tests := []struct { |
| 25 | +name string |
| 26 | +args []string |
| 27 | +fixture string |
| 28 | +}{ |
| 29 | +{"pgo show cluster", []string{"show", "cluster", TestClusterName}, ""}, |
| 30 | +} |
| 31 | + |
| 32 | +t.Log("TestShowCluster starts") |
| 33 | +for _, tt := range tests { |
| 34 | +cmd := exec.Command("pgo", tt.args...) |
| 35 | +output, err := cmd.CombinedOutput() |
| 36 | +if err != nil { |
| 37 | +//t.Fatal(err) |
| 38 | +} |
| 39 | + |
| 40 | +actual := string(output) |
| 41 | + |
| 42 | +t.Logf("actual %s- ", actual) |
| 43 | +cluster = "cluster : " + TestClusterName |
| 44 | +found := strings.Contains(actual, cluster) |
| 45 | +if !found { |
| 46 | +t.Error("could not find cluster : " + TestClusterName + "in output") |
| 47 | +} |
| 48 | + |
| 49 | +} |
| 50 | + |
| 51 | +t.Run("teardown", func(t *testing.T) { |
| 52 | +t.Log("some teardown code") |
| 53 | +}) |
| 54 | +} |
| 55 | + |
| 56 | +func TestShowNamespace(t *testing.T) { |
| 57 | +var clientset *kubernetes.Clientset |
| 58 | + |
| 59 | +// t.Fatal("not implemented") |
| 60 | +t.Run("setup", func(t *testing.T) { |
| 61 | +t.Log("some setup code") |
| 62 | +clientset, _ = SetupKube() |
| 63 | +if clientset == nil { |
| 64 | +t.Error("clientset is nil") |
| 65 | +} |
| 66 | +}) |
| 67 | + |
| 68 | +tests := []struct { |
| 69 | +name string |
| 70 | +args []string |
| 71 | +fixture string |
| 72 | +}{ |
| 73 | +{"pgo show namespace", []string{"show", "namespace"}, ""}, |
| 74 | +} |
| 75 | + |
| 76 | +t.Log("TestShowNamespace starts") |
| 77 | +for _, tt := range tests { |
| 78 | +cmd := exec.Command("pgo", tt.args...) |
| 79 | +output, err := cmd.CombinedOutput() |
| 80 | +if err != nil { |
| 81 | +//t.Fatal(err) |
| 82 | +} |
| 83 | + |
| 84 | +actual := string(output) |
| 85 | + |
| 86 | +t.Logf("actual %s- ", actual) |
| 87 | +found := strings.Contains(actual, Namespace) |
| 88 | +if !found { |
| 89 | +t.Error("could not find " + Namespace + "namespace in output") |
| 90 | +} |
| 91 | + |
| 92 | +} |
| 93 | + |
| 94 | +t.Run("teardown", func(t *testing.T) { |
| 95 | +t.Log("some teardown code") |
| 96 | +}) |
| 97 | +} |
| 98 | + |
| 99 | + |
| 100 | +func TestShowPvc(t *testing.T) { |
| 101 | +var clientset *kubernetes.Clientset |
| 102 | + |
| 103 | +// t.Fatal("not implemented") |
| 104 | +t.Run("setup", func(t *testing.T) { |
| 105 | +t.Log("some setup code") |
| 106 | +clientset, _ = SetupKube() |
| 107 | +if clientset == nil { |
| 108 | +t.Error("clientset is nil") |
| 109 | +} |
| 110 | +}) |
| 111 | + |
| 112 | +tests := []struct { |
| 113 | +name string |
| 114 | +args []string |
| 115 | +fixture string |
| 116 | +}{ |
| 117 | +{"pgo show pvc", []string{"show", "pvc", TestClusterName}, ""}, |
| 118 | +} |
| 119 | + |
| 120 | +t.Log("TestShowPvc starts") |
| 121 | +for _, tt := range tests { |
| 122 | +cmd := exec.Command("pgo", tt.args...) |
| 123 | +output, err := cmd.CombinedOutput() |
| 124 | +if err != nil { |
| 125 | +//t.Fatal(err) |
| 126 | +} |
| 127 | + |
| 128 | +actual := string(output) |
| 129 | + |
| 130 | +t.Logf("actual %s- ", actual) |
| 131 | +found := strings.Contains(actual, "pgdata") |
| 132 | +if !found { |
| 133 | +t.Error("could not find pgdata in output") |
| 134 | +} |
| 135 | + |
| 136 | +} |
| 137 | + |
| 138 | +t.Run("teardown", func(t *testing.T) { |
| 139 | +t.Log("some teardown code") |
| 140 | +}) |
| 141 | +} |
| 142 | + |
0 commit comments