| 56 | } |
| 57 | |
| 58 | func TestUpdateCmdMultiple(t *testing.T) { |
| 59 | var out bytes.Buffer |
| 60 | // Instead of using the HTTP updater, we provide our own for this test. |
| 61 | // The TestUpdateCharts test verifies the HTTP behavior independently. |
| 62 | updater := func(repos []*repo.ChartRepository, out io.Writer) error { |
| 63 | for _, re := range repos { |
| 64 | fmt.Fprintln(out, re.Config.Name) |
| 65 | } |
| 66 | return nil |
| 67 | } |
| 68 | o := &repoUpdateOptions{ |
| 69 | update: updater, |
| 70 | repoFile: "testdata/repositories.yaml", |
| 71 | names: []string{"firstexample", "charts"}, |
| 72 | } |
| 73 | if err := o.run(&out); err != nil { |
| 74 | t.Fatal(err) |
| 75 | } |
| 76 | |
| 77 | if got := out.String(); !strings.Contains(got, "charts") || |
| 78 | !strings.Contains(got, "firstexample") || |
| 79 | strings.Contains(got, "secondexample") { |
| 80 | t.Errorf("Expected 'charts' and 'firstexample' but not 'secondexample' but got %q", got) |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | func TestUpdateCmdInvalid(t *testing.T) { |
| 85 | var out bytes.Buffer |