Skip to content

Commit

Permalink
remove unnecessary check for not found kinds
Browse files Browse the repository at this point in the history
  • Loading branch information
miniscruff committed Sep 8, 2024
1 parent 886516c commit 8be2fad
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 26 deletions.
5 changes: 0 additions & 5 deletions cmd/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,12 +419,7 @@ func (b *Batch) WriteChanges(changes []core.Change) error {

if b.config.KindFormat != "" && lastKind != change.Kind {
lastKind = change.Kind

newKind := b.config.KindFromKeyOrLabel(change.Kind)
if newKind == nil {
return fmt.Errorf("kind not found by key or label: '%s'", change.Kind)
}

kindHeader := b.config.KindHeader(change.Kind)

err := b.WriteTemplate(
Expand Down
21 changes: 0 additions & 21 deletions cmd/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,27 +545,6 @@ func TestBatchWriteChanges(t *testing.T) {
then.Equals(t, expected, builder.String())
}

func TestBatchWriteChangesWithInvalidKind(t *testing.T) {
cfg := batchTestConfig()
then.WithTempDirConfig(t, cfg)

var builder strings.Builder

batch := NewBatch(time.Now, core.NewTemplateCache())
batch.config = cfg
batch.writer = &builder

changes := []core.Change{
{Kind: "added", Body: "w"},
{Kind: "added", Body: "x"},
{Kind: "removed", Body: "y"},
{Kind: "removed not found", Body: "z"},
}

err := batch.WriteChanges(changes)
then.NotNil(t, err)
}

func TestBatchCreateVersionsWithoutKindHeaders(t *testing.T) {
cfg := batchTestConfig()
cfg.KindFormat = ""
Expand Down

0 comments on commit 8be2fad

Please sign in to comment.