From 175ef8b587774e3fb5da3d870a2e6f47626b2e21 Mon Sep 17 00:00:00 2001 From: Beatriz Vieira Date: Fri, 12 Mar 2021 21:43:27 -0300 Subject: [PATCH] test: add empty issue key test issue: #13 --- sv/message_test.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sv/message_test.go b/sv/message_test.go index 620dbbc..ee78c8e 100644 --- a/sv/message_test.go +++ b/sv/message_test.go @@ -315,26 +315,26 @@ func TestMessageProcessorImpl_Parse(t *testing.T) { } func TestMessageProcessorImpl_Format(t *testing.T) { - p := NewMessageProcessor(ccfg, newBranchCfg(false)) - tests := []struct { name string + cfg CommitMessageConfig msg CommitMessage wantHeader string wantBody string wantFooter string }{ - {"simple message", NewCommitMessage("feat", "", "something", "", "", ""), "feat: something", "", ""}, - {"with issue", NewCommitMessage("feat", "", "something", "", "JIRA-123", ""), "feat: something", "", "jira: JIRA-123"}, - {"with breaking change", NewCommitMessage("feat", "", "something", "", "", "breaks"), "feat: something", "", "BREAKING CHANGE: breaks"}, - {"with scope", NewCommitMessage("feat", "scope", "something", "", "", ""), "feat(scope): something", "", ""}, - {"with body", NewCommitMessage("feat", "", "something", "body", "", ""), "feat: something", "body", ""}, - {"with multiline body", NewCommitMessage("feat", "", "something", multilineBody, "", ""), "feat: something", multilineBody, ""}, - {"full message", NewCommitMessage("feat", "scope", "something", multilineBody, "JIRA-123", "breaks"), "feat(scope): something", multilineBody, fullFooter}, + {"simple message", ccfg, NewCommitMessage("feat", "", "something", "", "", ""), "feat: something", "", ""}, + {"with issue", ccfg, NewCommitMessage("feat", "", "something", "", "JIRA-123", ""), "feat: something", "", "jira: JIRA-123"}, + {"with breaking change", ccfg, NewCommitMessage("feat", "", "something", "", "", "breaks"), "feat: something", "", "BREAKING CHANGE: breaks"}, + {"with scope", ccfg, NewCommitMessage("feat", "scope", "something", "", "", ""), "feat(scope): something", "", ""}, + {"with body", ccfg, NewCommitMessage("feat", "", "something", "body", "", ""), "feat: something", "body", ""}, + {"with multiline body", ccfg, NewCommitMessage("feat", "", "something", multilineBody, "", ""), "feat: something", multilineBody, ""}, + {"full message", ccfg, NewCommitMessage("feat", "scope", "something", multilineBody, "JIRA-123", "breaks"), "feat(scope): something", multilineBody, fullFooter}, + {"config without issue key", ccfgEmptyIssue, NewCommitMessage("feat", "", "something", "", "JIRA-123", ""), "feat: something", "", ""}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got, got1, got2 := p.Format(tt.msg) + got, got1, got2 := NewMessageProcessor(tt.cfg, newBranchCfg(false)).Format(tt.msg) if got != tt.wantHeader { t.Errorf("MessageProcessorImpl.Format() header got = %v, want %v", got, tt.wantHeader) }