forked from dyrector-io/dyrectorio
-
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: internal/helper/image_unit_test : use table driven tests (d…
…yrector-io#838) * refactor internal/helper/image_unit_test : use table driven tests Unit tests were spread across various functions, but most of them can be organized into table driven test cases. * refactor internal/helper/image/image_unit_test.go extract utility function Promot NewPTR as a general helper function . * refactor: internal/helper/image_unit_test : add name to table tests * feat: add tests to pointer module --------- Co-authored-by: Nandor Magyar <[email protected]> Co-authored-by: Levente Orban <[email protected]>
- Loading branch information
1 parent
ad9461e
commit 800cfad
Showing
3 changed files
with
65 additions
and
25 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,6 @@ | ||
package pointer | ||
|
||
// Creates a new pointer of type T | ||
func NewPTR[T any](value T) *T { | ||
return &value | ||
} |
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,15 @@ | ||
package pointer | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestNewPTR(t *testing.T) { | ||
sPtr := NewPTR[string]("") | ||
assert.Equal(t, *sPtr, "") | ||
|
||
iPtr := NewPTR[int](120) | ||
assert.Equal(t, *iPtr, 120) | ||
} |