Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Unit Tests

on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
workflow_dispatch:

jobs:
unit-tests:
name: Run Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true

- name: Run unit tests
run: make test

- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report-${{ github.run_number }}
path: cover.out
retention-days: 7
2 changes: 1 addition & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/controller/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ var _ = BeforeSuite(func() {

By("bootstrapping test environment")
testEnv = &envtest.Environment{
UseExistingCluster: ptr.To(true),
UseExistingCluster: ptr.To(false),
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
ErrorIfCRDPathMissing: true,

Expand Down
17 changes: 16 additions & 1 deletion internal/controller/vector_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,15 @@ var _ = Describe("Vector Controller", func() {
Name: resourceName,
Namespace: "default",
},
// TODO(user): Specify other spec details if needed.
Spec: v1alpha1.VectorSpec{
Agent: &v1alpha1.VectorAgent{
VectorCommon: v1alpha1.VectorCommon{
ConfigCheck: v1alpha1.ConfigCheck{
Disabled: true,
},
},
},
},
}
Expect(k8sClient.Create(ctx, resource)).To(Succeed())
}
Expand All @@ -78,10 +86,17 @@ var _ = Describe("Vector Controller", func() {
EventChan: make(chan event.GenericEvent, 1),
}

// First reconcile adds finalizer
_, err := controllerReconciler.Reconcile(ctx, reconcile.Request{
NamespacedName: typeNamespacedName,
})
Expect(err).NotTo(HaveOccurred())

// Second reconcile performs actual reconciliation
_, err = controllerReconciler.Reconcile(ctx, reconcile.Request{
NamespacedName: typeNamespacedName,
})
Expect(err).NotTo(HaveOccurred())
// TODO(user): Add more specific assertions depending on your controller's reconciliation logic.
// Example: If you expect a certain status condition after reconciliation, verify it here.
})
Expand Down