Skip to content

Commit

Permalink
fix: fixed fake custom entity panic issue (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
Prashansa-K authored Jan 24, 2025
1 parent c296111 commit da051e1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/file/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ func (f *FCustomEntity) UnmarshalJSON(b []byte) error {
}
return copyToFCustomEntity(entity, f)
default:
return fmt.Errorf("unknown entity type: %s", *f.Type)
return fmt.Errorf("unknown entity type: %s", temp["type"])
}
}

Expand Down
12 changes: 10 additions & 2 deletions tests/integration/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7593,7 +7593,7 @@ func Test_Sync_DegraphqlRoutes(t *testing.T) {
currentState, err := fetchCurrentState(ctx, client, dumpConfig)
require.NoError(t, err)

targetState := stateFromFile(ctx, t, "testdata/sync/036-degraphql-routes/kong.yaml", client, dumpConfig)
targetState := stateFromFile(ctx, t, "testdata/sync/037-degraphql-routes/kong.yaml", client, dumpConfig)
syncer, err := deckDiff.NewSyncer(deckDiff.SyncerOpts{
CurrentState: currentState,
TargetState: targetState,
Expand Down Expand Up @@ -7625,7 +7625,7 @@ func Test_Sync_DegraphqlRoutes(t *testing.T) {
currentState, err := fetchCurrentState(ctx, client, dumpConfig)
require.NoError(t, err)

targetState := stateFromFile(ctx, t, "testdata/sync/036-degraphql-routes/kong-complex-query.yaml", client, dumpConfig)
targetState := stateFromFile(ctx, t, "testdata/sync/037-degraphql-routes/kong-complex-query.yaml", client, dumpConfig)
syncer, err := deckDiff.NewSyncer(deckDiff.SyncerOpts{
CurrentState: currentState,
TargetState: targetState,
Expand Down Expand Up @@ -7654,3 +7654,11 @@ func Test_Sync_DegraphqlRoutes(t *testing.T) {
assert.Equal(t, expectedMethods, degraphqlRoutes[0].Methods)
})
}

func Test_Sync_CustomEntities_Fake(t *testing.T) {
runWhen(t, "enterprise", ">=3.0.0")
setup(t)
err := sync("testdata/sync/037-degraphql-routes/kong-fake-entity.yaml")
require.Error(t, err)
assert.ErrorContains(t, err, "unknown entity type: fake-entity")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
_format_version: "3.0"
custom_entities:
- type: fake-entity
fields:
foo: bar

0 comments on commit da051e1

Please sign in to comment.