Skip to content

HYPERFLEET-1183 - test: Adding additional integration tests for gaps …#225

Draft
ma-hill wants to merge 1 commit into
openshift-hyperfleet:mainfrom
ma-hill:HYPERFLEET-1183
Draft

HYPERFLEET-1183 - test: Adding additional integration tests for gaps …#225
ma-hill wants to merge 1 commit into
openshift-hyperfleet:mainfrom
ma-hill:HYPERFLEET-1183

Conversation

@ma-hill

@ma-hill ma-hill commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Refactors integration tests for Channels and Versions to use organized subtests with helper functions, reducing test boilerplate by 60-80%. Previously, tests were scattered across multiple files with significant duplication and inconsistent patterns. This consolidates all Channel and Version CRUD operations into two well-structured test files using t.Run() subtests, making tests easier to read, maintain, and debug.

HYPERFLEET-1183

Changes

  • Added test/integration/channels_test.go with comprehensive test coverage organized into 5 test groups:

    • TestChannelCreate (4 subtests): UniqueConstraint, EmptyName, WithLabels, SetsTimestamps
    • TestChannelDelete (4 subtests): NotFound, SetsDeletedTime, ReDeleteReturns404, HardDeleteRemovesRow
    • TestChannelList (3 subtests): Basic, Pagination, WithOrdering
    • TestChannelGet (2 subtests): NotFound, Success
    • TestChannelPatch (4 subtests): NotFound, SpecChanged, LabelsOnly, UpdatesTimestamps
  • Added test/integration/versions_test.go with comprehensive test coverage organized into 5 test groups:

    • TestVersionCreate (9 subtests): UniqueConstraintPerChannel, SameVersionNameInDifferentChannels, EmptyName, WrongParentKind, ParentDeleted, ParentNotFound, WithDeletedParent, WithLabels, SetsTimestamps
    • TestVersionDelete (6 subtests): CascadeFromChannel, NotFound, SetsDeletedTime, ReDeleteReturns404, HardDeleteRemovesRow, RestrictBlocksWithActiveParent
    • TestVersionList (4 subtests): ListByOwnerID, ListByLabel, Pagination, ByOwner
    • TestVersionGet (4 subtests): ByOwnerWrongParent, NotFound, ByOwnerNotFound, ByOwnerSuccess
    • TestVersionPatch (4 subtests): NotFound, SpecChanged, LabelsOnly, UpdatesTimestamps
  • Removed test/integration/resource_delete_test.go as delete tests are now organized within resource-specific test files

  • Updated .gitignore to exclude test output and temporary files

  • Updated Makefile with additional test coverage targets

  • Added pkg/services/resource_test.go with unit tests for List validation logic

Notes

All tests use UUID-based unique naming to prevent conflicts when running in parallel or against shared test databases. The helper functions follow the pattern established in the existing codebase where setup uses t.Fatalf() for fatal errors and test assertions use Gomega Expect() matchers.

Tests now properly validate through the service layer rather than directly mutating the database, ensuring all business logic and validation rules are exercised.

In conjunction with change: openshift-hyperfleet/hyperfleet-e2e#129

Test Plan

  • Unit tests added/updated
  • make test-all passes
  • make lint passes
  • make test-coverage shows improved coverage for Channel and Version operations
  • Integration tests validate database constraints and CRUD operations correctly

@openshift-ci openshift-ci Bot requested review from Mischulee and jsell-rh June 18, 2026 16:53
@openshift-ci

openshift-ci Bot commented Jun 18, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign jsell-rh for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are limited based on label configuration.

🚫 Excluded labels (none allowed) (2)
  • do-not-merge/work-in-progress
  • do-not-merge/hold

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 1adb0a6b-4c41-4c20-a3bf-049f7e16e8e2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
📝 Walkthrough

Walkthrough

.gitignore gains explicit patterns for coverage.out and its integration/filtered variants. The Makefile adds five new targets: test-coverage and test-coverage-integration (run tests with -coverprofile, strip generated-code paths, print totals), coverage-html/coverage-integration-html (open HTML reports via go tool cover), and coverage-clean (delete artifacts). Five unit tests are added to pkg/services/resource_test.go for ResourceService.List kind-filter injection. test/integration/resource_delete_test.go is removed; its helpers are extracted into a new resource_helpers.go. Full CRUD integration suites for Channel and Version are added in channels_test.go and versions_test.go.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 9 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.23% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive Title is truncated and incomplete ('…'), making it vague and non-descriptive about actual changes. Complete the title to clearly specify what test gaps are being addressed (e.g., 'Add comprehensive integration tests for Channel and Version CRUD operations').
✅ Passed checks (9 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Sec-02: Secrets In Log Output ✅ Passed No secrets found in log statements. The only non-test file with code is test/integration/resource_helpers.go, which contains no logging API calls (slog, log, logr, zap, fmt.Print*). The fmt.Errorf...
No Hardcoded Secrets ✅ Passed No hardcoded secrets detected in PR changes. All test data uses placeholder values (test@example.com, mock UUIDs, example image URLs). Coverage .gitignore entries are appropriate.
No Weak Cryptography ✅ Passed No banned cryptographic primitives (md5, des, rc4, SHA1 for security, ECB) or insecure practices detected. Test files use standard libraries without crypto operations.
No Injection Vectors ✅ Passed No injection vectors detected. SQL queries use parameterized statements (CWE-89), grep patterns are hardcoded (CWE-78), no template/YAML operations present (CWE-79/502).
No Privileged Containers ✅ Passed PR modifies only Go test files, .gitignore, and Makefile. No Kubernetes manifests, Helm templates, or Dockerfiles are present in the changeset.
No Pii Or Sensitive Data In Logs ✅ Passed No logging statements (slog, logr, zap, log., fmt.Print) found in added/modified files. Test data email "test@example.com" and resource IDs appear only in struct initialization and error returns...
Description check ✅ Passed The PR description clearly describes test refactoring for Channel and Version resources, detailing new test files, helper functions, and specific test coverage areas.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

Comment @coderabbitai help to get the list of available commands and usage tips.

@hyperfleet-ci-bot

hyperfleet-ci-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

Risk Score: 2 — risk/medium

Signal Detail Points
PR size 1578 lines (>500) +2
Sensitive paths none +0
Test coverage Tests cover changed packages +0

Computed by hyperfleet-risk-scorer

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/factories/channels.go`:
- Around line 50-74: The NewChannelWithLabels factory function is directly
mutating channel labels via database writes instead of using the
resources.Service validation and patch logic, which can cause integration tests
to miss label-handling regressions. Replace the direct database update calls
(the dbSession.Model and Update operations) with a call to the appropriate
resources.Service method that properly validates and patches labels, ensuring
the factory follows the same code path as production usage.

In `@test/integration/channels_test.go`:
- Around line 64-67: The test assertion in the channel creation block expects a
500 Internal Server Error when creating a channel with an empty Spec field, but
empty Spec is malformed client input that should be validated at the system
boundary and return a 400 Bad Request error instead. Modify the assertion that
checks svcErr.HTTPCode to expect 400 (Equal(400)) rather than 500, and update
the corresponding assertion message to reflect that this is a client input
validation error rather than an internal server error.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: ca5b332c-c51a-45b9-97dd-1fc73eb0ab05

📥 Commits

Reviewing files that changed from the base of the PR and between 3b8f405 and f681172.

📒 Files selected for processing (9)
  • .gitignore
  • Makefile
  • pkg/services/resource_test.go
  • test/factories/channels.go
  • test/factories/versions.go
  • test/integration/channels_test.go
  • test/integration/resource_delete_test.go
  • test/integration/resource_helpers.go
  • test/integration/versions_test.go
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift-hyperfleet/architecture (manual)
  • openshift-hyperfleet/hyperfleet-api (manual)
  • openshift-hyperfleet/hyperfleet-sentinel (manual)
  • openshift-hyperfleet/hyperfleet-adapter (manual)
  • openshift-hyperfleet/hyperfleet-broker (manual)
💤 Files with no reviewable changes (1)
  • test/integration/resource_delete_test.go

Comment thread test/factories/channels.go Outdated
Comment thread test/integration/channels_test.go Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/factories/channels.go`:
- Around line 25-28: The Create method call for the Channel resource is
returning raw errors without wrapping them with call-site context. Replace the
bare return err statements (both the one after resourceService.Create and the
similar one mentioned at lines 37-40) with wrapped errors that include
contextual information about the channel being created, such as the channel ID
or index. Use Go's error wrapping pattern with fmt.Errorf and the %w verb to
maintain the original error while adding descriptive context that will help with
debugging integration setup failures.

In `@test/integration/channels_test.go`:
- Around line 409-410: The test on line 409 discards the resource returned by
the Create method call and instead relies on implicit mutation of the input
defaultChannel object. This is problematic because if Create does not mutate the
input pointer to populate the ID field, the later comparison at lines 434-439
will fail when it tries to use defaultChannel.ID. Fix this by capturing the
returned resource from the svc.Create call into a variable and use that returned
resource's ID field for the comparison instead of relying on the input parameter
being mutated.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: e5863093-4982-46ca-a26d-c14ec24e604c

📥 Commits

Reviewing files that changed from the base of the PR and between dd00745 and c059b0e.

📒 Files selected for processing (9)
  • .gitignore
  • Makefile
  • pkg/services/resource_test.go
  • test/factories/channels.go
  • test/factories/versions.go
  • test/integration/channels_test.go
  • test/integration/resource_delete_test.go
  • test/integration/resource_helpers.go
  • test/integration/versions_test.go
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift-hyperfleet/architecture (manual)
  • openshift-hyperfleet/hyperfleet-api (manual)
  • openshift-hyperfleet/hyperfleet-sentinel (manual)
  • openshift-hyperfleet/hyperfleet-adapter (manual)
  • openshift-hyperfleet/hyperfleet-broker (manual)
💤 Files with no reviewable changes (1)
  • test/integration/resource_delete_test.go
✅ Files skipped from review due to trivial changes (1)
  • .gitignore
🚧 Files skipped from review as they are similar to previous changes (3)
  • pkg/services/resource_test.go
  • test/factories/versions.go
  • test/integration/versions_test.go

Comment thread test/factories/channels.go Outdated
Comment thread test/integration/channels_test.go Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/integration/resource_helpers.go`:
- Line 21: The checkResourceCount function creates a DB session using
context.Background() at line 21, which prevents propagation of test context and
can cause unbounded hangs. Add a ctx context.Context parameter to the
checkResourceCount function signature, then replace the context.Background()
call in the dbSession initialization with the passed ctx parameter. Update all
test call sites that invoke checkResourceCount to pass the appropriate test
context (typically the test's *testing.T context or a timeout-bounded context)
instead of relying on the background context.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 942ba138-7a68-4df5-9c3a-9d42a25d9704

📥 Commits

Reviewing files that changed from the base of the PR and between c059b0e and 046150f.

📒 Files selected for processing (7)
  • .gitignore
  • Makefile
  • pkg/services/resource_test.go
  • test/integration/channels_test.go
  • test/integration/resource_delete_test.go
  • test/integration/resource_helpers.go
  • test/integration/versions_test.go
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift-hyperfleet/architecture (manual)
  • openshift-hyperfleet/hyperfleet-api (manual)
  • openshift-hyperfleet/hyperfleet-sentinel (manual)
  • openshift-hyperfleet/hyperfleet-adapter (manual)
  • openshift-hyperfleet/hyperfleet-broker (manual)
💤 Files with no reviewable changes (1)
  • test/integration/resource_delete_test.go
✅ Files skipped from review due to trivial changes (1)
  • .gitignore
🚧 Files skipped from review as they are similar to previous changes (3)
  • pkg/services/resource_test.go
  • test/integration/channels_test.go
  • test/integration/versions_test.go

}

func checkResourceCount(h *test.Helper, ids []string, expected int64) error {
dbSession := h.DBFactory.New(context.Background())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Propagate test context into DB session creation to prevent unbounded hangs (CWE-400).

Line 21 creates the DB session with context.Background(), which drops caller cancellation/timeouts. Update checkResourceCount to accept ctx context.Context and pass it through from each test call site.

As per coding guidelines, "Propagate context.Context — flag context.Background() when parent context exists."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/integration/resource_helpers.go` at line 21, The checkResourceCount
function creates a DB session using context.Background() at line 21, which
prevents propagation of test context and can cause unbounded hangs. Add a ctx
context.Context parameter to the checkResourceCount function signature, then
replace the context.Background() call in the dbSession initialization with the
passed ctx parameter. Update all test call sites that invoke checkResourceCount
to pass the appropriate test context (typically the test's *testing.T context or
a timeout-bounded context) instead of relying on the background context.

Source: Coding guidelines

@ma-hill ma-hill marked this pull request as draft June 18, 2026 19:55

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/integration/channels_test.go`:
- Around line 70-80: The json.Marshal and json.Unmarshal operations in the test
are discarding their error return values, which can hide encoding/decoding
failures and produce false test results. Replace the underscore placeholder in
the json.Marshal call that sets channel.Labels with an actual error variable and
add an Expect assertion to verify the error is nil. Similarly, capture the error
returned by the json.Unmarshal call when unmarshaling into retrievedLabels
(instead of ignoring it) and add an Expect assertion to verify that error is
also nil before proceeding with the label comparison assertion.

In `@test/integration/versions_test.go`:
- Around line 371-374: The assertion on the version.ID in the test loop is
incorrectly using BeNil() on a string type, which cannot be nil. In the
createTestVersion function call loop where version.ID is being checked, replace
Expect(version.ID).ToNot(BeNil()) with Expect(version.ID).ToNot(BeEmpty()) to
properly assert that the string ID is not empty rather than attempting an
invalid nil-check on a non-pointer type.
- Around line 152-153: The json.Marshal call in the test setup is ignoring its
error return value by using the blank identifier, which violates error handling
guidelines and can corrupt test preconditions. Capture the error returned by
json.Marshal(labels) instead of discarding it with underscore, then add an
assertion to verify the error is nil before proceeding with the svc.Create call.
Apply the same fix to all other occurrences of this pattern in the file (also at
lines 328-336) where errors are being silently ignored.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: f3b513d9-3d45-4c16-84ee-7cd97cbd506e

📥 Commits

Reviewing files that changed from the base of the PR and between 046150f and 069613e.

📒 Files selected for processing (7)
  • .gitignore
  • Makefile
  • pkg/services/resource_test.go
  • test/integration/channels_test.go
  • test/integration/resource_delete_test.go
  • test/integration/resource_helpers.go
  • test/integration/versions_test.go
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift-hyperfleet/architecture (manual)
  • openshift-hyperfleet/hyperfleet-api (manual)
  • openshift-hyperfleet/hyperfleet-sentinel (manual)
  • openshift-hyperfleet/hyperfleet-adapter (manual)
  • openshift-hyperfleet/hyperfleet-broker (manual)
💤 Files with no reviewable changes (1)
  • test/integration/resource_delete_test.go
✅ Files skipped from review due to trivial changes (1)
  • .gitignore
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/services/resource_test.go

Comment on lines +70 to +80
channel.Labels, _ = json.Marshal(labels)
createdChannel, svcErr := svc.Create(context.Background(), "Channel", channel)
Expect(svcErr).To(BeNil())
Expect(createdChannel.Labels).NotTo(BeNil())

// Get the resource and verify labels persisted
retrieved, getErr := svc.Get(context.Background(), "Channel", createdChannel.ID)
Expect(getErr).To(BeNil(), "should retrieve channel")
var retrievedLabels map[string]string
json.Unmarshal(retrieved.Labels, &retrievedLabels)
Expect(retrievedLabels).To(Equal(labels), "retrieved labels should match")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Stop discarding JSON encode/decode errors in assertions.

json.Marshal/json.Unmarshal errors are ignored in multiple assertions, which can silently invalidate test intent and produce false positives/negatives (CWE-393). Check every returned error before comparing payloads.
As per coding guidelines, "Error handling (ERR-01 to ERR-04): every error return MUST be checked — flag silently discarded errors."

Also applies to: 309-321, 344-346

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/integration/channels_test.go` around lines 70 - 80, The json.Marshal and
json.Unmarshal operations in the test are discarding their error return values,
which can hide encoding/decoding failures and produce false test results.
Replace the underscore placeholder in the json.Marshal call that sets
channel.Labels with an actual error variable and add an Expect assertion to
verify the error is nil. Similarly, capture the error returned by the
json.Unmarshal call when unmarshaling into retrievedLabels (instead of ignoring
it) and add an Expect assertion to verify that error is also nil before
proceeding with the label comparison assertion.

Source: Coding guidelines

Comment on lines +152 to +153
version.Labels, _ = json.Marshal(labels)
createdVersion, svcErr := svc.Create(context.Background(), "Version", version)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Do not ignore json.Marshal errors in test setup.

Discarding marshal errors in setup can corrupt test preconditions and mask root causes (CWE-703). Assert the error is nil before create calls.
As per coding guidelines, "Error handling (ERR-01 to ERR-04): every error return MUST be checked — flag silently discarded errors."

Also applies to: 328-336

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/integration/versions_test.go` around lines 152 - 153, The json.Marshal
call in the test setup is ignoring its error return value by using the blank
identifier, which violates error handling guidelines and can corrupt test
preconditions. Capture the error returned by json.Marshal(labels) instead of
discarding it with underscore, then add an assertion to verify the error is nil
before proceeding with the svc.Create call. Apply the same fix to all other
occurrences of this pattern in the file (also at lines 328-336) where errors are
being silently ignored.

Source: Coding guidelines

Comment on lines +371 to +374
for i := range 15 {
version := createTestVersion(t, svc, fmt.Sprintf("version-%d", i), channel.ID)
Expect(version.ID).ToNot(BeNil())
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fix invalid nil-check on string ID assertion.

Line 373 asserts version.ID (string) with BeNil(), which is always wrong for non-pointer types and can fail deterministically. Use NotTo(BeEmpty()) instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/integration/versions_test.go` around lines 371 - 374, The assertion on
the version.ID in the test loop is incorrectly using BeNil() on a string type,
which cannot be nil. In the createTestVersion function call loop where
version.ID is being checked, replace Expect(version.ID).ToNot(BeNil()) with
Expect(version.ID).ToNot(BeEmpty()) to properly assert that the string ID is not
empty rather than attempting an invalid nil-check on a non-pointer type.

expectCreateError(svc, version, 404, "wrong parent kind should fail")
})

t.Run("ParentDeleted", func(t *testing.T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this tests duplicating WithDeletedParent?

But, does it even make sense to try to create a Version with a Deleted Channel?

Isn't it the same as the ParentNotFound one?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you're right


// Version Delete
func TestVersionDelete(t *testing.T) {
t.Run("CascadeFromChannel", func(t *testing.T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this test is a bit misleading.

Reading the name CascadeFromChannel I would expect that the OnParentDeletePolicy for Versions should be cascade and that we don't need to manually delete the Versions like is happening here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kinda over thought out these tests I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants