This repository was archived by the owner on Oct 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
WIP: Add Tests #31
Open
okwme
wants to merge
17
commits into
master
Choose a base branch
from
okwme/tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
WIP: Add Tests #31
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
8cf4c00
added most basic tests for scaffold function
okwme 2ea5dd9
gomod
okwme c1bd197
add github actions
tac0turtle 2bd960c
fix GA
tac0turtle 94912d3
fix GA
tac0turtle f079de2
fix GA
tac0turtle 864cc8f
fix GA 3000
tac0turtle 671c499
fix GA 300 only test
tac0turtle f543495
fix GA 300 only test
tac0turtle 1b9102f
fix GA 300 only test
tac0turtle 7502c3c
fix GA 300 only test 5
tac0turtle f9a3fc7
minor cleanup
tac0turtle 7998fae
b in build
tac0turtle 7c103f2
b in build
tac0turtle ff72c19
set path
tac0turtle 66f0a55
fix set path
tac0turtle 1442ec2
set path
tac0turtle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,32 @@ | ||
| name: Go | ||
| on: [pull_request] | ||
| jobs: | ||
| test: | ||
| name: Test | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Set up Go 1.13 | ||
| uses: actions/setup-go@v1 | ||
| with: | ||
| go-version: 1.13 | ||
| id: go | ||
|
|
||
| # This is used since the above action does not set it for now | ||
| # Remove once https://github.com/actions/setup-go/issues/27 is fixed | ||
| - name: setup env | ||
| run: | | ||
| echo "::set-env name=GOPATH::$(go env GOPATH)" | ||
| echo "::add-path::$(go env GOPATH)/bin" | ||
| shell: bash | ||
|
|
||
| - name: Check out code into the Go module directory | ||
| uses: actions/checkout@v1 | ||
|
|
||
| - name: Tools | ||
| run: make tools | ||
|
|
||
| - name: Build | ||
| run: make build | ||
|
|
||
| - name: Test | ||
| run: make test |
This file contains hidden or 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 hidden or 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,113 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "io/ioutil" | ||
| "log" | ||
| "os" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/iancoleman/strcase" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestScaffoldTutorialNameservice(t *testing.T) { | ||
| tmp, err := ioutil.TempDir("", "scaffold-test-") | ||
| if err != nil { | ||
| log.Fatal(err) | ||
| } | ||
| defer os.RemoveAll(tmp) // clean up | ||
| os.Chdir(tmp) | ||
|
|
||
| user := "username" | ||
| repo := "repository" | ||
| dir := "nameservice" | ||
| nameRaw := dir | ||
| nameCapitalCamelCase := strcase.ToCamel(nameRaw) | ||
| nameLowerCamelCase := strcase.ToLowerCamel(nameRaw) | ||
| nameLowerCase := strings.ToLower(nameLowerCamelCase) | ||
| ns := UserRepoArgs{ | ||
| Dir: dir, | ||
| User: user, | ||
| Repo: repo, | ||
| NameRaw: nameRaw, | ||
| NameLowerCase: nameLowerCase, | ||
| NameCapitalCamelCase: nameCapitalCamelCase, | ||
| NameLowerCamelCase: nameLowerCamelCase, | ||
| } | ||
| err = scaffold(dir, outputPath, ns) | ||
| require.NoError(t, err) | ||
| } | ||
| func TestScaffoldTutorialHelloChain(t *testing.T) { | ||
| tmp, err := ioutil.TempDir("", "scaffold-test-") | ||
| if err != nil { | ||
| log.Fatal(err) | ||
| } | ||
| defer os.RemoveAll(tmp) // clean up | ||
| os.Chdir(tmp) | ||
|
|
||
| user := "username" | ||
| repo := "repository" | ||
| dir := "hellochain" | ||
| nameRaw := dir | ||
| nameCapitalCamelCase := strcase.ToCamel(nameRaw) | ||
| nameLowerCamelCase := strcase.ToLowerCamel(nameRaw) | ||
| nameLowerCase := strings.ToLower(nameLowerCamelCase) | ||
| ns := UserRepoArgs{ | ||
| Dir: dir, | ||
| User: user, | ||
| Repo: repo, | ||
| NameRaw: nameRaw, | ||
| NameLowerCase: nameLowerCase, | ||
| NameCapitalCamelCase: nameCapitalCamelCase, | ||
| NameLowerCamelCase: nameLowerCamelCase, | ||
| } | ||
| err = scaffold(dir, outputPath, ns) | ||
| require.NoError(t, err) | ||
| } | ||
|
|
||
| func TestScaffoldApp(t *testing.T) { | ||
| tmp, err := ioutil.TempDir("", "scaffold-test-") | ||
| if err != nil { | ||
| log.Fatal(err) | ||
| } | ||
| defer os.RemoveAll(tmp) // clean up | ||
| os.Chdir(tmp) | ||
|
|
||
| lvl := "lvl-1" | ||
| dir := lvl | ||
| user := "username" | ||
| repo := "repository" | ||
|
|
||
| ns := UserRepoArgs{ | ||
| Dir: dir, | ||
| User: user, | ||
| Repo: repo, | ||
| } | ||
| err = scaffold(dir, outputPath, ns) | ||
| require.NoError(t, err) | ||
| } | ||
|
|
||
| func TestScaffoldModule(t *testing.T) { | ||
| tmp, err := ioutil.TempDir("", "scaffold-test-") | ||
| if err != nil { | ||
| log.Fatal(err) | ||
| } | ||
| // defer os.RemoveAll(tmp) // clean up | ||
| os.Chdir(tmp) | ||
|
|
||
| dir := "module" | ||
| user := "username" | ||
| repo := "repository" | ||
| nameRaw := "myModule" | ||
| nameLowerCase := strings.ToLower(nameRaw) | ||
| mdl := UserRepoArgs{ | ||
| User: user, | ||
| Repo: repo, | ||
| Dir: dir, | ||
| NameRaw: nameRaw, | ||
| NameLowerCase: nameLowerCase, | ||
| } | ||
| err = scaffold(dir, outputPath, mdl) | ||
| require.NoError(t, err) | ||
| } | ||
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we also build/run the app here? Or is that better done in CI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can do app level scaffolding but not module level, which i think is fine. I can spend time next week working on this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think app level is fine for now and adding module support to the testing at a later date.