|
|
@ -82,28 +82,13 @@ func TestLoadIndexFile(t *testing.T) {
|
|
|
|
verifyLocalIndex(t, i)
|
|
|
|
verifyLocalIndex(t, i)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestMergeIndex(t *testing.T) {
|
|
|
|
func TestMerge(t *testing.T) {
|
|
|
|
dirName, err := ioutil.TempDir("", "tmp")
|
|
|
|
ind1 := NewIndexFile()
|
|
|
|
if err != nil {
|
|
|
|
ind1.Add(&chart.Metadata{
|
|
|
|
t.Fatal(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
defer os.RemoveAll(dirName)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ind := NewIndexFile()
|
|
|
|
|
|
|
|
ind.Add(&chart.Metadata{
|
|
|
|
|
|
|
|
Name: "dreadnought",
|
|
|
|
Name: "dreadnought",
|
|
|
|
Version: "0.1.0",
|
|
|
|
Version: "0.1.0",
|
|
|
|
}, "dreadnought-0.1.0.tgz", "http://example.com", "aaaa")
|
|
|
|
}, "dreadnought-0.1.0.tgz", "http://example.com", "aaaa")
|
|
|
|
|
|
|
|
|
|
|
|
cr := &ChartRepository{
|
|
|
|
|
|
|
|
IndexFile: ind,
|
|
|
|
|
|
|
|
RootPath: dirName,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if err := cr.saveIndexFile(); err != nil {
|
|
|
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ind2 := NewIndexFile()
|
|
|
|
ind2 := NewIndexFile()
|
|
|
|
ind2.Add(&chart.Metadata{
|
|
|
|
ind2.Add(&chart.Metadata{
|
|
|
|
Name: "dreadnought",
|
|
|
|
Name: "dreadnought",
|
|
|
@ -113,25 +98,12 @@ func TestMergeIndex(t *testing.T) {
|
|
|
|
Name: "doughnut",
|
|
|
|
Name: "doughnut",
|
|
|
|
Version: "0.2.0",
|
|
|
|
Version: "0.2.0",
|
|
|
|
}, "doughnut-0.2.0.tgz", "http://example.com", "ccccbbbb")
|
|
|
|
}, "doughnut-0.2.0.tgz", "http://example.com", "ccccbbbb")
|
|
|
|
cr.IndexFile = ind2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ind3, err := LoadIndexFile(filepath.Join(dirName, "index.yaml"))
|
|
|
|
ind1.Merge(ind2)
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if err := cr.MergeIndex(ind3); err != nil {
|
|
|
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ind4, err := LoadIndexFile(filepath.Join(dirName, "index.yaml"))
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(ind4.Entries) != 2 {
|
|
|
|
if len(ind1.Entries) != 2 {
|
|
|
|
t.Errorf("Expected 2 entries, got %d", len(ind4.Entries))
|
|
|
|
t.Errorf("Expected 2 entries, got %d", len(ind1.Entries))
|
|
|
|
vs := ind4.Entries["dreadnaught"]
|
|
|
|
vs := ind1.Entries["dreadnaught"]
|
|
|
|
if len(vs) != 2 {
|
|
|
|
if len(vs) != 2 {
|
|
|
|
t.Errorf("Expected 2 versions, got %d", len(vs))
|
|
|
|
t.Errorf("Expected 2 versions, got %d", len(vs))
|
|
|
|
}
|
|
|
|
}
|
|
|
|