Skip to content

Commit

Permalink
Make test struct consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
Maarten van der Heijden committed Sep 5, 2023
1 parent 53907cf commit 50c1c8c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
26 changes: 13 additions & 13 deletions generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,19 +526,19 @@ func TestInjectLinks_ReturnsJsonOnUnknownType(t *testing.T) {
func TestInjectLinks_IgnoresIfNoTypeRegistered(t *testing.T) {
t.Parallel()
// Arrange
type DeepType1 struct {
type deepType1 struct {
ID int `json:"id"`
Name string `json:"name"`
}
type TestType1 struct {
Deep *DeepType1 `json:"deep"`
type testType1 struct {
Deep *deepType1 `json:"deep"`
}

registry := NewLinkRegistry()
RegisterOn(registry, empty{}, Self("", ""))

object := &TestType1{
Deep: &DeepType1{ID: 23, Name: "test"},
object := &testType1{
Deep: &deepType1{ID: 23, Name: "test"},
}

// Act
Expand All @@ -556,14 +556,14 @@ func TestInjectLinks_IgnoresIfNoTypeRegisteredOnSlice(t *testing.T) {
ID int `json:"id"`
Name string `json:"name"`
}
type TestType2 struct {
type testType2 struct {
Deep *DeepType2 `json:"deep"`
}

registry := NewLinkRegistry()
RegisterOn(registry, empty{}, Self("", ""))

object := []*TestType2{
object := []*testType2{
{Deep: &DeepType2{ID: 23, Name: "test"}},
{Deep: &DeepType2{ID: 7, Name: "other"}},
}
Expand Down Expand Up @@ -595,12 +595,12 @@ func TestInjectLinks_IgnoresOnNonStructSlices(t *testing.T) {
func TestInjectLinks_IgnoresIfRegistryIsEmpty(t *testing.T) {
t.Parallel()
// Arrange
type TestType3 struct {
type testType3 struct {
}

registry := NewLinkRegistry()

object := &TestType3{}
object := &testType3{}

// Act
result := InjectLinks(registry, object)
Expand All @@ -613,7 +613,7 @@ func TestInjectLinks_IgnoresIfRegistryIsEmpty(t *testing.T) {
func TestGetFieldNameFromJson_ReturnsExpectedName(t *testing.T) {
t.Parallel()

type TestType3 struct {
type testType3 struct {
Name string `json:"name"`
Deep int `json:"deep,omitempty"`
}
Expand All @@ -637,7 +637,7 @@ func TestGetFieldNameFromJson_ReturnsExpectedName(t *testing.T) {
t.Run(name, func(t *testing.T) {
t.Parallel()
// Act
result, err := getFieldNameFromJson(TestType3{}, testData.jsonKey)
result, err := getFieldNameFromJson(testType3{}, testData.jsonKey)

// Assert
assert.NoError(t, err)
Expand All @@ -649,10 +649,10 @@ func TestGetFieldNameFromJson_ReturnsExpectedName(t *testing.T) {
func TestGetFieldNameFromJson_ReturnsEmptyStringOnNonStructType(t *testing.T) {
t.Parallel()
// Arrange
type TestType4s []string
type testType4s []string

// Act
result, err := getFieldNameFromJson(TestType4s{}, "any")
result, err := getFieldNameFromJson(testType4s{}, "any")

// Assert
assert.EqualError(t, err, "object is not a struct")
Expand Down
12 changes: 6 additions & 6 deletions registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ import (
func TestGetTypeName_ReturnsNameOnTypeA(t *testing.T) {
t.Parallel()
// Arrange
type TestTypeA struct{}
type testTypeA struct{}

// Act
result := typeNameOf(new(TestTypeA))
result := typeNameOf(new(testTypeA))

// Assert
assert.Equal(t, "gohateoas.TestTypeA", result)
assert.Equal(t, "gohateoas.testTypeA", result)
}

func TestGetTypeName_ReturnsNameOnTypeB(t *testing.T) {
t.Parallel()
// Arrange
type TestTypeB struct{}
type testTypeB struct{}

// Act
result := typeNameOf(new(*****[]*[]*[]****TestTypeB))
result := typeNameOf(new(*****[]*[]*[]****testTypeB))

// Assert
assert.Equal(t, "gohateoas.TestTypeB", result)
assert.Equal(t, "gohateoas.testTypeB", result)
}

type TestRegisterOnType struct{}
Expand Down

0 comments on commit 50c1c8c

Please sign in to comment.