Skip to content

Fix/test infra gameserver#26

Draft
NAME-ASHWANIYADAV wants to merge 2 commits into
agones-dev:mainfrom
NAME-ASHWANIYADAV:fix/test-infra-gameserver
Draft

Fix/test infra gameserver#26
NAME-ASHWANIYADAV wants to merge 2 commits into
agones-dev:mainfrom
NAME-ASHWANIYADAV:fix/test-infra-gameserver

Conversation

@NAME-ASHWANIYADAV

@NAME-ASHWANIYADAV NAME-ASHWANIYADAV commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Draft — depends on #25 . Will be marked ready for review after those PRs merge and this branch is rebased.

Type of change

  • 🐛 Bug fix
  • 🚀 New feature / enhancement
  • 📖 Documentation
  • 🧹 Refactoring / cleanup
  • ⚙️ CI / tooling
  • ⚠️ Breaking change

What this PR does

Introduces Vitest testing infrastructure and adds 29 unit tests for the GameServer resource model.

Testing infra:

  • vitest.config.ts - Configures Vitest with jsdom environment and aliases @kinvolk/headlamp-plugin/lib/k8s/cluster to a lightweight mock (the real path is externalized at build time and cannot be resolved in tests).
  • src/__testutils__/kubeObjectMock.ts - Minimal KubeObject stand-in verified against the real Headlamp source.
  • package.json - Updates the test script from headlamp-plugin test to vitest run.

GameServer tests (29 tests):

  • Static fields, state, address, nodeName, fleet, ports, counters, lists, eviction, addresses, reservedUntil, mergedPorts.
  • Edge cases: missing status, empty arrays, default values.

Did you use AI tools in preparing this PR?:
Y

Test plan

Automated checks

  • npm ci
  • npm run build
  • npm run tsc
  • npm run lint
  • npm run format -- --check
  • npm run test

Manual verification

N/A - test infrastructure and unit tests only.

Notes for reviewers

The KubeObject mock was verified against the real Headlamp source (this.jsonData = json, get metadata() { return this.jsonData.metadata }). The eviction getter defaults to 'Never', matching the upstream Agones Go code (EvictionSafeNever in gameserver.go:486).

Signed-off-by: ashwani yadav <22ashwaniyadav@gmail.com>
Signed-off-by: ashwani yadav <22ashwaniyadav@gmail.com>
@NAME-ASHWANIYADAV NAME-ASHWANIYADAV marked this pull request as draft June 23, 2026 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant