(t *testing.T)
| 54 | } |
| 55 | |
| 56 | func TestNew(t *testing.T) { |
| 57 | globalCfg = config.New(t.TempDir()) |
| 58 | setupTestDir(t, []*chlog.Entry{}) |
| 59 | |
| 60 | var out string |
| 61 | var err error |
| 62 | |
| 63 | out, err = runCobra(t, "new", "--filename", "my-change") |
| 64 | assert.Contains(t, out, fmt.Sprintf("Changelog entry template copied to: %s", filepath.Join(globalCfg.EntriesDir, "my-change.yaml"))) |
| 65 | assert.Empty(t, err) |
| 66 | |
| 67 | out, err = runCobra(t, "new", "--filename", "some-change.yaml") |
| 68 | assert.Contains(t, out, fmt.Sprintf("Changelog entry template copied to: %s", filepath.Join(globalCfg.EntriesDir, "some-change.yaml"))) |
| 69 | assert.Empty(t, err) |
| 70 | |
| 71 | out, err = runCobra(t, "new", "--filename", "some-change.yml") |
| 72 | assert.Contains(t, out, fmt.Sprintf("Changelog entry template copied to: %s", filepath.Join(globalCfg.EntriesDir, "some-change.yaml"))) |
| 73 | assert.Empty(t, err) |
| 74 | |
| 75 | out, err = runCobra(t, "new", "--filename", "replace/forward/slash") |
| 76 | assert.Contains(t, out, fmt.Sprintf("Changelog entry template copied to: %s", filepath.Join(globalCfg.EntriesDir, "replace_forward_slash.yaml"))) |
| 77 | assert.Empty(t, err) |
| 78 | |
| 79 | out, err = runCobra(t, "new", "--filename", "not.an.extension") |
| 80 | assert.Contains(t, out, fmt.Sprintf("Changelog entry template copied to: %s", filepath.Join(globalCfg.EntriesDir, "not.an.extension.yaml"))) |
| 81 | assert.Empty(t, err) |
| 82 | |
| 83 | out, err = runCobra(t, "new", "--filename", "my-change.txt") |
| 84 | assert.Contains(t, out, fmt.Sprintf("Changelog entry template copied to: %s", filepath.Join(globalCfg.EntriesDir, "my-change.txt.yaml"))) |
| 85 | assert.Empty(t, err) |
| 86 | } |
| 87 | |
| 88 | func TestCleanFilename(t *testing.T) { |
| 89 | assert.Equal(t, "fix_some_bug", cleanFileName("fix/some_bug")) |
nothing calls this directly
no test coverage detected