-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move generate workflow to FSM
- Loading branch information
1 parent
b30c543
commit 6a48c41
Showing
8 changed files
with
190 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package fsm_util | ||
|
||
type State = string | ||
type Event = string | ||
|
||
func Before(event Event) string { | ||
return "before_" + event | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package git_test | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/handofgod94/gh-jira-changelog/pkg/jira_changelog/git" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestCommits(t *testing.T) { | ||
testCases := []struct { | ||
desc string | ||
gitOutput git.GitOutput | ||
want []git.Commit | ||
wantErr bool | ||
}{ | ||
{ | ||
desc: "returns commits when gitoutput is valid", | ||
gitOutput: git.GitOutput(` | ||
(1687839814) {3cefgdr} use extra space while generating template | ||
(1688059937) {4567uge} [JIRA-123] refactor: extract out structs from jira/types | ||
(1687799347) {3456cdw} add warning emoji for changelog lineitem | ||
`), | ||
want: []git.Commit{ | ||
{ | ||
Message: "use extra space while generating template", | ||
Time: time.Unix(1687839814, 0), | ||
Sha: "3cefgdr", | ||
}, | ||
{ | ||
Message: "[JIRA-123] refactor: extract out structs from jira/types", | ||
Time: time.Unix(1688059937, 0), | ||
Sha: "4567uge", | ||
}, | ||
{ | ||
Message: "add warning emoji for changelog lineitem", | ||
Time: time.Unix(1687799347, 0), | ||
Sha: "3456cdw", | ||
}, | ||
}, | ||
}, | ||
{ | ||
desc: "returns single commit if gitoutput has single line", | ||
gitOutput: git.GitOutput(` | ||
(1688059937) {3456cdw} refactor: extract out structs from jira/types | ||
`), | ||
want: []git.Commit{{Message: "refactor: extract out structs from jira/types", Time: time.Unix(1688059937, 0), Sha: "3456cdw"}}, | ||
}, | ||
{ | ||
desc: "returns error when output is not in correct format", | ||
gitOutput: git.GitOutput(`foobar`), | ||
wantErr: true, | ||
}, | ||
{ | ||
desc: "returns error when output is empty", | ||
gitOutput: git.GitOutput(""), | ||
wantErr: true, | ||
}, | ||
} | ||
for _, tc := range testCases { | ||
t.Run(tc.desc, func(t *testing.T) { | ||
got, err := tc.gitOutput.Commits() | ||
if tc.wantErr { | ||
assert.Error(t, err) | ||
} else { | ||
assert.NoError(t, err) | ||
assert.Equal(t, tc.want, got) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
checks = ["all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022", "-ST1023", "-ST1001"] | ||
initialisms = ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", "SIP", "RTP", "AMQP", "DB", "TS"] | ||
dot_import_whitelist = ["github.com/mmcloughlin/avo/build", "github.com/mmcloughlin/avo/operand", "github.com/mmcloughlin/avo/reg"] | ||
http_status_code_whitelist = ["200", "400", "404", "500"] |