-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generate mains for apis in build folder
- Loading branch information
Ivan Vlasic
committed
Dec 3, 2021
1 parent
399aafa
commit 0f71832
Showing
7 changed files
with
125 additions
and
75 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
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 |
---|---|---|
@@ -1,51 +1,47 @@ | ||
package controller | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestExtractApiStructNamePtr(t *testing.T) { | ||
stc, err := extractApiStructName("ping", "testdata/generate/ping_ptr") | ||
func TestIsNewValidPtr(t *testing.T) { | ||
err := isNewValid("ping", "testdata/generate/ping_ptr") | ||
require.NoError(t, err) | ||
assert.Equal(t, "Ping", stc) | ||
} | ||
|
||
func TestExtractApiStructNameStruct(t *testing.T) { | ||
stc, err := extractApiStructName("ping", "testdata/generate/ping_struct") | ||
func TestIsNewValidStruct(t *testing.T) { | ||
err := isNewValid("ping", "testdata/generate/ping_struct") | ||
require.NoError(t, err) | ||
assert.Equal(t, "Ping", stc) | ||
} | ||
|
||
func TestExtractApiStructNameNoNew(t *testing.T) { | ||
_, err := extractApiStructName("ping", "testdata/generate/no_new") | ||
fmt.Println(err) | ||
func TestIsNewValidNoNew(t *testing.T) { | ||
err := isNewValid("ping", "testdata/generate/no_new") | ||
require.Error(t, err) | ||
} | ||
|
||
func TestExtractApiStructNameNewWithParameters(t *testing.T) { | ||
_, err := extractApiStructName("ping", "testdata/generate/parameters") | ||
fmt.Println(err) | ||
func TestIsNewValidWithParameters(t *testing.T) { | ||
err := isNewValid("ping", "testdata/generate/parameters") | ||
require.Error(t, err) | ||
} | ||
|
||
func TestExtractApiStructNameTooManyValues(t *testing.T) { | ||
_, err := extractApiStructName("ping", "testdata/generate/return_values") | ||
fmt.Println(err) | ||
func TestIsNewValidTooManyReturnValues(t *testing.T) { | ||
err := isNewValid("ping", "testdata/generate/return_values") | ||
require.Error(t, err) | ||
} | ||
|
||
func TestExtractApiStructNameWrongValue(t *testing.T) { | ||
_, err := extractApiStructName("ping", "testdata/generate/return_value") | ||
fmt.Println(err) | ||
func TestIsNewValidWrongReturnValue(t *testing.T) { | ||
err := isNewValid("ping", "testdata/generate/return_value") | ||
require.Error(t, err) | ||
} | ||
|
||
func TestExtractApiStructNameNewWrongType(t *testing.T) { | ||
_, err := extractApiStructName("ping", "testdata/generate/new_wrong_type") | ||
fmt.Println(err) | ||
func TestIsNewValidNewWrongType(t *testing.T) { | ||
err := isNewValid("ping", "testdata/generate/new_wrong_type") | ||
require.Error(t, err) | ||
} | ||
|
||
func TestIsNewValidMethod(t *testing.T) { | ||
err := isNewValid("ping", "testdata/generate/new_method") | ||
require.Error(t, err) | ||
} |
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,5 @@ | ||
package ping | ||
|
||
type Ping struct{} | ||
|
||
func (p Ping) New() {} |