(t *testing.T)
| 144 | } |
| 145 | |
| 146 | func TestCheckKubeContext(t *testing.T) { |
| 147 | context1 := "context1" |
| 148 | context2 := "context2" |
| 149 | ns1 := "n1" |
| 150 | ns2 := "ns2" |
| 151 | |
| 152 | localCache := &localcache.LocalCache{ |
| 153 | LastContext: &localcache.LastContextConfig{ |
| 154 | Context: context1, |
| 155 | Namespace: ns1, |
| 156 | }, |
| 157 | } |
| 158 | |
| 159 | testCases := []testCaseContext{ |
| 160 | { |
| 161 | // selecting last context |
| 162 | selectContext: context1, |
| 163 | namespace: ns1, // ns2 should be reverted to back to ns1 |
| 164 | }, |
| 165 | { |
| 166 | // selecting current context |
| 167 | selectContext: context2, |
| 168 | namespace: ns2, // same ns should be used |
| 169 | }, |
| 170 | } |
| 171 | |
| 172 | clusters := make(map[string]*api.Cluster) |
| 173 | clusters["cluster1"] = &api.Cluster{ |
| 174 | Server: "server1", |
| 175 | } |
| 176 | clusters["cluster2"] = &api.Cluster{ |
| 177 | Server: "server2", |
| 178 | } |
| 179 | |
| 180 | contexts := make(map[string]*api.Context) |
| 181 | contexts[context1] = &api.Context{ |
| 182 | Cluster: "cluster1", |
| 183 | } |
| 184 | contexts[context2] = &api.Context{ |
| 185 | Cluster: "cluster2", |
| 186 | } |
| 187 | |
| 188 | loader := &configTesting.Loader{ |
| 189 | RawConfig: &api.Config{ |
| 190 | Clusters: clusters, |
| 191 | Contexts: contexts, |
| 192 | }, |
| 193 | } |
| 194 | |
| 195 | fakeLogger := fakelogger.NewFakeLogger() |
| 196 | fakeLogger.SetLevel(4) |
| 197 | |
| 198 | for _, tc := range testCases { |
| 199 | // creating client |
| 200 | client, err := NewClientFromContext(context2, ns2, false, loader) |
| 201 | if err != nil { |
| 202 | t.Fatal(err) |
| 203 | } |
nothing calls this directly
no test coverage detected