-
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.
added tests and added actions/setup-go@v4
- Loading branch information
Showing
14 changed files
with
290 additions
and
26 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package api | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/gofiber/fiber/v2" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type ApiTests struct { | ||
suite.Suite | ||
} | ||
|
||
func TestApi(t *testing.T) { | ||
suite.Run(t, &ApiTests{}) | ||
} | ||
|
||
func (t ApiTests) Test_WithFiber() { | ||
app := fiber.New() | ||
t.Empty(app.GetRoutes()) | ||
WithFiber(app) | ||
t.NotEmpty(app.GetRoutes()) | ||
} |
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,55 @@ | ||
package types | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/gofiber/fiber/v2" | ||
"github.com/stretchr/testify/suite" | ||
"github.com/valyala/fasthttp" | ||
) | ||
|
||
type HttpResponseTests struct { | ||
suite.Suite | ||
} | ||
|
||
func TestApi(t *testing.T) { | ||
suite.Run(t, &HttpResponseTests{}) | ||
} | ||
|
||
func (t HttpResponseTests) Test_WithFiber() { | ||
app := fiber.New() | ||
bodyData := "hello world" | ||
errorMessage := "error" | ||
customMessage := "this will be overridden by the error" | ||
statusCode := http.StatusTeapot | ||
|
||
c := app.AcquireCtx(&fasthttp.RequestCtx{}) | ||
r := HttpResponse{ | ||
Data: bodyData, | ||
Error: errors.New(errorMessage), | ||
Message: &customMessage, | ||
StatusCode: statusCode, | ||
} | ||
r.WithFiber(c) | ||
t.EqualValues(statusCode, c.Response().StatusCode()) | ||
t.EqualValues( | ||
fmt.Sprintf(`{"data":"%s","message":"%s"}`, bodyData, errorMessage), | ||
string(c.Response().Body()), | ||
"message field should be overridden if there are errors", | ||
) | ||
r = HttpResponse{ | ||
Data: bodyData, | ||
Message: &customMessage, | ||
StatusCode: statusCode, | ||
} | ||
r.WithFiber(c) | ||
t.EqualValues(statusCode, c.Response().StatusCode()) | ||
t.EqualValues( | ||
fmt.Sprintf(`{"data":"%s","message":"%s"}`, bodyData, customMessage), | ||
string(c.Response().Body()), | ||
"message field should not be overridden if there are no errors", | ||
) | ||
} |
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,23 @@ | ||
package kafka | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type ConfigTests struct { | ||
suite.Suite | ||
} | ||
|
||
func TestConfig(t *testing.T) { | ||
suite.Run(t, &ConfigTests{}) | ||
} | ||
|
||
func (t ConfigTests) Test_WithCobra() { | ||
c := cobra.Command{} | ||
t.False(c.HasFlags()) | ||
WithCobra(&c) | ||
t.True(c.HasFlags()) | ||
} |
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,23 @@ | ||
package mongo | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type ConfigTests struct { | ||
suite.Suite | ||
} | ||
|
||
func TestConfig(t *testing.T) { | ||
suite.Run(t, &ConfigTests{}) | ||
} | ||
|
||
func (t ConfigTests) Test_WithCobra() { | ||
c := cobra.Command{} | ||
t.False(c.HasFlags()) | ||
WithCobra(&c) | ||
t.True(c.HasFlags()) | ||
} |
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,23 @@ | ||
package mysql | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type ConfigTests struct { | ||
suite.Suite | ||
} | ||
|
||
func TestConfig(t *testing.T) { | ||
suite.Run(t, &ConfigTests{}) | ||
} | ||
|
||
func (t ConfigTests) Test_WithCobra() { | ||
c := cobra.Command{} | ||
t.False(c.HasFlags()) | ||
WithCobra(&c) | ||
t.True(c.HasFlags()) | ||
} |
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,23 @@ | ||
package nats | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type ConfigTests struct { | ||
suite.Suite | ||
} | ||
|
||
func TestConfig(t *testing.T) { | ||
suite.Run(t, &ConfigTests{}) | ||
} | ||
|
||
func (t ConfigTests) Test_WithCobra() { | ||
c := cobra.Command{} | ||
t.False(c.HasFlags()) | ||
WithCobra(&c) | ||
t.True(c.HasFlags()) | ||
} |
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,23 @@ | ||
package postgres | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type ConfigTests struct { | ||
suite.Suite | ||
} | ||
|
||
func TestConfig(t *testing.T) { | ||
suite.Run(t, &ConfigTests{}) | ||
} | ||
|
||
func (t ConfigTests) Test_WithCobra() { | ||
c := cobra.Command{} | ||
t.False(c.HasFlags()) | ||
WithCobra(&c) | ||
t.True(c.HasFlags()) | ||
} |
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,23 @@ | ||
package redis | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type ConfigTests struct { | ||
suite.Suite | ||
} | ||
|
||
func TestConfig(t *testing.T) { | ||
suite.Run(t, &ConfigTests{}) | ||
} | ||
|
||
func (t ConfigTests) Test_WithCobra() { | ||
c := cobra.Command{} | ||
t.False(c.HasFlags()) | ||
WithCobra(&c) | ||
t.True(c.HasFlags()) | ||
} |
Oops, something went wrong.