-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5404a48
commit 88b03d0
Showing
21 changed files
with
1,105 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -262,6 +262,17 @@ func existingDocumentState() *state.KongState { | |
return s | ||
} | ||
|
||
func existingDeveloperState() *state.KongState { | ||
s, _ := state.NewKongState() | ||
s.Developers.Add(state.Developer{ | ||
Developer: kong.Developer{ | ||
ID: kong.String("4bfcb11f-c962-4817-83e5-9433cf20b663"), | ||
Email: kong.String("foo"), | ||
}, | ||
}) | ||
return s | ||
} | ||
|
||
var deterministicUUID = func() *string { | ||
version := byte(4) | ||
uuid := make([]byte, 16) | ||
|
@@ -2489,3 +2500,77 @@ func Test_stateBuilder_fillPluginConfig(t *testing.T) { | |
}) | ||
} | ||
} | ||
|
||
func Test_stateBuilder_developers(t *testing.T) { | ||
assert := assert.New(t) | ||
rand.Seed(42) | ||
type fields struct { | ||
currentState *state.KongState | ||
targetContent *Content | ||
} | ||
tests := []struct { | ||
name string | ||
fields fields | ||
want *utils.KongRawState | ||
}{ | ||
{ | ||
name: "generates ID for a non-existing developer", | ||
fields: fields{ | ||
targetContent: &Content{ | ||
Developers: []FDeveloper{ | ||
{ | ||
Developer: kong.Developer{ | ||
Email: kong.String("[email protected]"), | ||
}, | ||
}, | ||
}, | ||
}, | ||
currentState: emptyState(), | ||
}, | ||
want: &utils.KongRawState{ | ||
Developers: []*kong.Developer{ | ||
{ | ||
ID: kong.String("538c7f96-b164-4f1b-97bb-9f4bb472e89f"), | ||
Email: kong.String("[email protected]"), | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "matches ID of an existing Developer", | ||
fields: fields{ | ||
targetContent: &Content{ | ||
Developers: []FDeveloper{ | ||
{ | ||
Developer: kong.Developer{ | ||
Email: kong.String("[email protected]"), | ||
}, | ||
}, | ||
}, | ||
}, | ||
currentState: existingDeveloperState(), | ||
}, | ||
want: &utils.KongRawState{ | ||
Developers: []*kong.Developer{ | ||
{ | ||
ID: kong.String("5b1484f2-5209-49d9-b43e-92ba09dd9d52"), | ||
Email: kong.String("[email protected]"), | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
b := &stateBuilder{ | ||
targetContent: tt.fields.targetContent, | ||
currentState: tt.fields.currentState, | ||
} | ||
d, _ := utils.GetKongDefaulter() | ||
b.defaulter = d | ||
b.build() | ||
assert.Equal(tt.want, b.rawState) | ||
}) | ||
} | ||
} |
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
Oops, something went wrong.