Skip to content

Commit

Permalink
use new cache in test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Engquist committed Sep 20, 2018
1 parent 1d9fbc1 commit 1a4456a
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,18 @@ func init() {
"pod1.json",
"pod2.json",
"pod3.json"} {
addToCache(&cache, "testdata/"+fname)
addToTestCache(&cache, "testdata/"+fname)
}
}

func addToCache(cacheref *map[string]interface{}, fname string) {
func addToTestCache(cacheref *map[string]interface{}, fname string) {
bytes, err := ioutil.ReadFile(fname)
if err != nil {
log.Fatal(err)
}
data := fromJson(bytes).(JsonObject)
kind := data["kind"].(string)
ns := getNamespace(data)
name := getName(data)
(*cacheref)[cacheKey(kind, ns, name)] = data
existing := (*cacheref)[kind]
if existing == nil {
(*cacheref)[kind] = []JsonObject{data}
} else {
(*cacheref)[kind] = append(existing.([]JsonObject), data)
}
nsKey := nsCacheKey(kind, ns)
nsExisting := (*cacheref)[nsKey]
if nsExisting == nil {
(*cacheref)[nsKey] = []JsonObject{data}
} else {
(*cacheref)[nsKey] = append(existing.([]JsonObject), data)
}
cache := GetCache()
cache.Add(&data)
}

func TestPods(t *testing.T) {
Expand Down

0 comments on commit 1a4456a

Please sign in to comment.