helm/pkg/repo/local_test.go

42 lines
776 B
Go
Raw Normal View History

2016-05-10 02:40:10 +08:00
package repo
import (
"testing"
)
const testfile = "testdata/local-index.yaml"
2016-05-10 02:40:10 +08:00
func TestLoadIndexFile(t *testing.T) {
cf, err := LoadIndexFile(testfile)
2016-05-10 02:40:10 +08:00
if err != nil {
t.Errorf("Failed to load index file: %s", err)
2016-05-10 02:40:10 +08:00
}
if len(cf.Entries) != 2 {
t.Errorf("Expected 2 entries in the index file, but got %d", len(cf.Entries))
2016-05-10 02:40:10 +08:00
}
nginx := false
alpine := false
for k, e := range cf.Entries {
if k == "nginx-0.1.0" {
if e.Name == "nginx" {
if len(e.Keywords) == 3 {
nginx = true
}
}
}
if k == "alpine-1.0.0" {
if e.Name == "alpine" {
if len(e.Keywords) == 4 {
alpine = true
}
}
}
}
if !nginx {
t.Errorf("nginx entry was not decoded properly")
}
if !alpine {
t.Errorf("alpine entry was not decoded properly")
}
}