Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
130086a
style: give every file the licence header, in one shape
retr0h Sep 7, 2026
7367ebc
style: put one parameter per line in signatures
retr0h Sep 7, 2026
bf6214f
test: carry validateFunc in the HTTP wiring tables
retr0h Sep 7, 2026
0a7e96d
test: carry validateFunc in the processor tables
retr0h Sep 7, 2026
0146ec5
docs: say what the coverage figure leaves out
retr0h Sep 7, 2026
f815c70
test: carry validateFunc where the loop ended in a comparison
retr0h Sep 7, 2026
6aeadee
test: carry validateFunc in the stub and CLI tables
retr0h Sep 7, 2026
3164dfb
test: carry validateFunc in the rest of the stub tables
retr0h Sep 7, 2026
caaffef
test: carry validateFunc in the validation and subject tables
retr0h Sep 7, 2026
9883d5e
refactor: take the pointer helpers from k8s.io/utils/ptr
retr0h Sep 7, 2026
34aeba2
test: name the audit fixture for what it holds
retr0h Sep 7, 2026
b99dcd5
test: carry validateFunc in the remaining error-branch tables
retr0h Sep 7, 2026
122fa50
test: carry validateFunc in stub tables asserting a zero value
retr0h Sep 7, 2026
8052ec5
test: carry validateFunc where the whole tail was the assertion
retr0h Sep 7, 2026
974922f
test: name the validate column validateFunc
retr0h Sep 7, 2026
f76ef83
test: drop the tables that had nothing to table
retr0h Sep 7, 2026
f4817ac
Revert "test: drop the tables that had nothing to table"
retr0h Sep 7, 2026
5caf580
test: hand the result to the row in the tables the tools missed
retr0h Sep 7, 2026
1c5b9e0
test: move the loop's trailing assertions into the rows
retr0h Sep 7, 2026
91b95fc
test: hand the recorder to the row in the handler tables
retr0h Sep 7, 2026
83dae8e
test: hand the result to the row where the assertions used assert
retr0h Sep 7, 2026
32ef09c
test: hand the result to the row where the expectation was a struct
retr0h Sep 7, 2026
7814546
test: give the validation and job tables their own expectations
retr0h Sep 7, 2026
ac5e95f
test: hand over where the loop still has work after the call
retr0h Sep 7, 2026
d888be3
test: hand over in the tables the guards had wrongly skipped
retr0h Sep 7, 2026
1f9dd85
test: restore the assertions the handler tables had lost
retr0h Sep 7, 2026
bfebe9a
test: hand over what the loop produced in the last hand-worked tables
retr0h Sep 7, 2026
8059c75
test: hand over in the last tables the tools could reach
retr0h Sep 7, 2026
7bb6b6f
test: hand the loop's own variables to the rows that assert on them
retr0h Sep 7, 2026
9c31fa2
test: hand over the seed, template and error tables
retr0h Sep 7, 2026
d15d50e
test: hand the call to the row where the expectation is that it holds
retr0h Sep 7, 2026
a2d4241
test: give the row callbacks the type the call returns
retr0h Sep 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ A test file is named for the production file it tests. Where tests grow too
large to read, split the production file first so each test file keeps a
counterpart, rather than splitting tests away from the file they cover.

A test file that holds no tests is named for what it holds, not for the fact
that other tests use it. `support`, `fixture` and `helper` describe where the
code was put; `sha256_public_test.go` and `test_agent_public_test.go` say what
is in them. Where only one test file needs the code, it belongs in that file.

### Go patterns

- Error wrapping: `fmt.Errorf("context: %w", err)`, so the chain names each
Expand Down Expand Up @@ -302,6 +307,10 @@ just go-unit-cov-check # Report coverage and fail below the target
The target is declared in `.github/codecov.yml` and in the shared `go` justfile
module. Change both together.

What the figure covers is narrowed by `.coverignore`, which excludes `/cmd/`,
`/gen/`, `/mocks/`, `/ui/` and `main.go`. A percentage read without that file in
mind will not match what the gate measures.

### Test file conventions

- Public tests: `*_public_test.go` in the package's `_test` package, exercising
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[![release](https://img.shields.io/github/release/osapi-io/osapi.svg?style=for-the-badge)](https://github.com/osapi-io/osapi/releases/latest)
[![codecov](https://img.shields.io/codecov/c/github/osapi-io/osapi?token=NF0T86B1EP&style=for-the-badge)](https://codecov.io/gh/osapi-io/osapi)
[![go report card](https://goreportcard.com/badge/github.com/osapi-io/osapi?style=for-the-badge)](https://goreportcard.com/report/github.com/osapi-io/osapi)
[![license](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=for-the-badge)](LICENSE)
[![build](https://img.shields.io/github/actions/workflow/status/osapi-io/osapi/go.yml?style=for-the-badge)](https://github.com/osapi-io/osapi/actions/workflows/go.yml)
[![docker](https://img.shields.io/badge/ghcr.io-osapi-blue?style=for-the-badge&logo=docker&logoColor=white)](https://github.com/osapi-io/osapi/pkgs/container/osapi)
Expand Down
3 changes: 2 additions & 1 deletion cmd/client_audit_export.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package cmd
import (
"context"
"fmt"
"log/slog"
"strconv"

"github.com/osapi-io/osapi/pkg/sdk/client"
Expand Down Expand Up @@ -81,7 +82,7 @@ func writeExport(

defer func() {
if closeErr := exporter.Close(ctx); closeErr != nil {
logger.Error("closing exporter", "error", closeErr)
logger.Error("closing exporter", slog.Any("error", closeErr))
}
}()

Expand Down
8 changes: 6 additions & 2 deletions cmd/controller_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,9 @@ func newHealthChecker(

// configuredKVBuckets returns the namespaced names of all KV buckets
// declared in osapi.yaml. Only non-empty bucket configs are included.
func configuredKVBuckets(namespace string) []string {
func configuredKVBuckets(
namespace string,
) []string {
var buckets []string
for _, info := range appConfig.NATS.AllKVBuckets() {
if info.Bucket != "" {
Expand All @@ -400,7 +402,9 @@ func configuredKVBuckets(namespace string) []string {

// configuredObjectBuckets returns the namespaced names of all Object Store
// buckets declared in osapi.yaml.
func configuredObjectBuckets(namespace string) []string {
func configuredObjectBuckets(
namespace string,
) []string {
var buckets []string
for _, info := range appConfig.NATS.AllObjectStoreBuckets() {
if info.Bucket != "" {
Expand Down
4 changes: 3 additions & 1 deletion cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ func (c *compositeLifecycle) Start() {
}
}

func (c *compositeLifecycle) Stop(ctx context.Context) {
func (c *compositeLifecycle) Stop(
ctx context.Context,
) {
var wg sync.WaitGroup
for _, comp := range c.components {
wg.Add(1)
Expand Down
12 changes: 6 additions & 6 deletions examples/sdk/client/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/osapi-io/osapi/examples/sdk/client

go 1.25.0
go 1.26.0

replace github.com/osapi-io/osapi => ../../../

Expand All @@ -9,12 +9,12 @@ require github.com/osapi-io/osapi v0.0.0
require (
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/logr v1.4.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/oapi-codegen/runtime v1.6.0 // indirect
github.com/oapi-codegen/runtime v1.7.0 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/otel v1.44.0 // indirect
go.opentelemetry.io/otel/metric v1.44.0 // indirect
go.opentelemetry.io/otel/trace v1.44.0 // indirect
go.opentelemetry.io/otel v1.46.0 // indirect
go.opentelemetry.io/otel/metric v1.46.0 // indirect
go.opentelemetry.io/otel/trace v1.46.0 // indirect
)
32 changes: 14 additions & 18 deletions examples/sdk/client/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvF
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8=
github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
Expand All @@ -19,23 +17,21 @@ github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE=
github.com/oapi-codegen/nullable v1.1.0 h1:eAh8JVc5430VtYVnq00Hrbpag9PFRGWLjxR1/3KntMs=
github.com/oapi-codegen/nullable v1.1.0/go.mod h1:KUZ3vUzkmEKY90ksAmit2+5juDIhIZhfDl+0PwOQlFY=
github.com/oapi-codegen/runtime v1.6.0 h1:7Xx+GlueD6nRuyKoCPzL434Jfi3BetbiJOrzCHp/VPU=
github.com/oapi-codegen/runtime v1.6.0/go.mod h1:GwV7hC2hviaMzj+ITfHVRESK5J2W/GefVwIND/bMGvU=
github.com/oapi-codegen/runtime v1.7.0 h1:t7358VYPvNbWJ9gdAkIK/smVeHpBf6yp8VTsaZsb/7k=
github.com/oapi-codegen/runtime v1.7.0/go.mod h1:GwV7hC2hviaMzj+ITfHVRESK5J2W/GefVwIND/bMGvU=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE=
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
go.opentelemetry.io/otel v1.44.0 h1:JjwHmHpA4iZ3wBxluu2fbbE7j4kqlE8jXyAyPXH7HqU=
go.opentelemetry.io/otel v1.44.0/go.mod h1:BMgjTHL9WPRlRjL2oZCBTL4whCGtXch2H4BhOPIAyYc=
go.opentelemetry.io/otel/metric v1.44.0 h1:1w0gILTcHdr3YI+ixLyjemwrVnsMURbTZFrSYCdDdmc=
go.opentelemetry.io/otel/metric v1.44.0/go.mod h1:8O7hanEPBNgEMmybD3s2VBKcgWOCsA6tzHBPODAiquo=
go.opentelemetry.io/otel/trace v1.44.0 h1:jxF5CsGYCe74MCRx2X4g7WsY/VBKRqqpNvXlX/6gtIk=
go.opentelemetry.io/otel/trace v1.44.0/go.mod h1:oLl1jrMQAVo6v3GAggN+1VH9VIz9iUSvW53sW1Q8PIE=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
go.opentelemetry.io/otel v1.46.0 h1:FHt5/CDyVxi/8IM1CH7VE/rRgq3kLHa2mSTVMO8AWyc=
go.opentelemetry.io/otel v1.46.0/go.mod h1:Gj3SEScelsNC45tp4nSxRYlS+f5iez7W8XPMCt905kE=
go.opentelemetry.io/otel/metric v1.46.0 h1:yBnkXvgV7AXFILZc5K6IZe/CBFF3OS7BJ8ov6/lj0K8=
go.opentelemetry.io/otel/metric v1.46.0/go.mod h1:iPmdWqifKUdzziPkvvzIJXITl56fQx2mGM/DHLB3/2o=
go.opentelemetry.io/otel/trace v1.46.0 h1:OULy7ccdJnZtJ0UDYFOIGaCmiWzJ8Vi2G/Rsu60qs1c=
go.opentelemetry.io/otel/trace v1.46.0/go.mod h1:J7GAXweO77XSFkB/rmAqk9D6ihszhFjLU+d9WuUxDLI=
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
4 changes: 2 additions & 2 deletions examples/sdk/platform/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/osapi-io/osapi/examples/sdk/platform

go 1.25.0
go 1.26.0

replace github.com/osapi-io/osapi => ../../../

Expand All @@ -12,7 +12,7 @@ require (
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
github.com/shirou/gopsutil/v4 v4.26.7 // indirect
github.com/shirou/gopsutil/v4 v4.26.8 // indirect
github.com/tklauser/go-sysconf v0.3.16 // indirect
github.com/tklauser/numcpus v0.11.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
Expand Down
16 changes: 6 additions & 10 deletions examples/sdk/platform/go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
github.com/avfs/avfs v0.35.0 h1:dc0noSyEoVDtAUQlhHX0uRYBfI2aFbI8nF0XPtV/Ozw=
github.com/avfs/avfs v0.35.0/go.mod h1:LnzrUO5acMU5NCkohHcUN15YrnkxiJ/lRLQOZSp39ow=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/ebitengine/purego v0.10.2 h1:W809HbnvzAxgdm+aOvlSekrM16wGCdT/e76+9tS7gzE=
github.com/ebitengine/purego v0.10.2/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
Expand All @@ -11,24 +9,22 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU=
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/shirou/gopsutil/v4 v4.26.7 h1:IXzpHz/dkMRYAhKkOXr1HB6SuzWU3eoyyeWe7g3bNZc=
github.com/shirou/gopsutil/v4 v4.26.7/go.mod h1:5O9FjBiXoTDFatIWjZZosqj4pV0DRtLx598xGbBehzM=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/shirou/gopsutil/v4 v4.26.8 h1:YQMTF/1J50B5+Y0vlo1eDRf5DoR7Gk69hY+8wjYkQeo=
github.com/shirou/gopsutil/v4 v4.26.8/go.mod h1:5O9FjBiXoTDFatIWjZZosqj4pV0DRtLx598xGbBehzM=
github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE=
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
github.com/tklauser/go-sysconf v0.3.16 h1:frioLaCQSsF5Cy1jgRBrzr6t502KIIwQ0MArYICU0nA=
github.com/tklauser/go-sysconf v0.3.16/go.mod h1:/qNL9xxDhc7tx3HSRsLWNnuzbVfh3e7gh/BmM179nYI=
github.com/tklauser/numcpus v0.11.0 h1:nSTwhKH5e1dMNsCdVBukSZrURJRoHbSEQjdEbY+9RXw=
github.com/tklauser/numcpus v0.11.0/go.mod h1:z+LwcLq54uWZTX0u/bGobaV34u6V7KNlTZejzM6/3MQ=
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ require (
go.opentelemetry.io/proto/otlp v1.11.0
go.uber.org/mock v0.6.0
golang.org/x/term v0.45.0
k8s.io/utils v0.0.0-20260707023825-cf1189d6abe3
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1542,6 +1542,8 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.7.0 h1:w6WUp1VbkqPEgLz4rkBzH/CSU6HkoqNLp6GstyTx3lU=
honnef.co/go/tools v0.7.0/go.mod h1:pm29oPxeP3P82ISxZDgIYeOaf9ta6Pi0EWvCFoLG2vc=
k8s.io/utils v0.0.0-20260707023825-cf1189d6abe3 h1:jVkFFVfXdXP74B/zbO3hM3hpSFD0xvhQ5U686DPurkE=
k8s.io/utils v0.0.0-20260707023825-cf1189d6abe3/go.mod h1:M2s5JB1lIYP3jzZdorPLHXIPJzt9vv2muW5a6L9DtNM=
mvdan.cc/gofumpt v0.11.0 h1:0H01XB95PnN2QgCSR9ELdZyTlJqNZ7181B0BTMh5VZc=
mvdan.cc/gofumpt v0.11.0/go.mod h1:BeT5wCsOJt6J9zT2MZIOGszjUHzFkn1/l9g6xAzqsXo=
mvdan.cc/unparam v0.0.0-20251027182757-5beb8c8f8f15 h1:ssMzja7PDPJV8FStj7hq9IKiuiKhgz9ErWw+m68e7DI=
Expand Down
79 changes: 41 additions & 38 deletions internal/agent/agent_public_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,22 +144,24 @@ func (s *AgentPublicTestSuite) buildAgent() *agent.Agent {

func (s *AgentPublicTestSuite) TestNew() {
tests := []struct {
name string
name string
validateFunc func(*agent.Agent)
}{
{
name: "creates agent with all providers",
validateFunc: func(a *agent.Agent) {
s.NotNil(a)

a.SetSubComponents(map[string]job.SubComponentInfo{
"agent.heartbeat": {Status: "ok"},
})
},
},
}

for _, tt := range tests {
s.Run(tt.name, func() {
a := s.buildAgent()

s.NotNil(a)

a.SetSubComponents(map[string]job.SubComponentInfo{
"agent.heartbeat": {Status: "ok"},
})
tt.validateFunc(s.buildAgent())
})
}
}
Expand Down Expand Up @@ -449,18 +451,19 @@ func (s *AgentPublicTestSuite) TestStart() {

func (s *AgentPublicTestSuite) TestIsReady() {
tests := []struct {
name string
setupFunc func() *agent.Agent
wantErr bool
errMsg string
name string
setupFunc func() *agent.Agent
validateFunc func(error)
}{
{
name: "returns error when agent not started",
setupFunc: func() *agent.Agent {
return s.buildAgent()
},
wantErr: true,
errMsg: "agent not started",
validateFunc: func(err error) {
s.Error(err)
s.Contains(err.Error(), "agent not started")
},
},
{
name: "returns nil when agent is started",
Expand All @@ -486,31 +489,34 @@ func (s *AgentPublicTestSuite) TestIsReady() {

return a
},
wantErr: false,
validateFunc: func(err error) {
s.NoError(err)
},
},
}

for _, tt := range tests {
s.Run(tt.name, func() {
a := tt.setupFunc()
err := a.IsReady()

if tt.wantErr {
s.Error(err)
s.Contains(err.Error(), tt.errMsg)
} else {
s.NoError(err)
}
tt.validateFunc(a.IsReady())
})
}
}

func (s *AgentPublicTestSuite) TestSetMeterProvider() {
tests := []struct {
name string
name string
validateFunc func(*metrics.Server, *agent.Agent)
}{
{
name: "creates OTEL instruments without panic",
validateFunc: func(srv *metrics.Server, a *agent.Agent) {
s.Require().NotNil(srv)

s.NotPanics(func() {
a.SetMeterProvider(srv.MeterProvider())
})
},
},
}

Expand All @@ -520,11 +526,7 @@ func (s *AgentPublicTestSuite) TestSetMeterProvider() {

port := s.getFreePort()
srv := metrics.New("127.0.0.1", port, slog.Default())
s.Require().NotNil(srv)

s.NotPanics(func() {
a.SetMeterProvider(srv.MeterProvider())
})
tt.validateFunc(srv, a)

ctx, cancel := context.WithTimeout(
context.Background(),
Expand All @@ -539,27 +541,28 @@ func (s *AgentPublicTestSuite) TestSetMeterProvider() {

func (s *AgentPublicTestSuite) TestLastHeartbeatTime() {
tests := []struct {
name string
wantZero bool
name string
validateFunc func(time.Time)
}{
{
name: "returns zero time before any heartbeat",
wantZero: true,
name: "returns zero time before any heartbeat",
validateFunc: func(got time.Time) {
s.True(got.IsZero())
},
},
}

for _, tt := range tests {
s.Run(tt.name, func() {
a := s.buildAgent()

got := a.LastHeartbeatTime()
if tt.wantZero {
s.True(got.IsZero())
}
tt.validateFunc(a.LastHeartbeatTime())
})
}
}

func TestAgentPublicTestSuite(t *testing.T) {
func TestAgentPublicTestSuite(
t *testing.T,
) {
suite.Run(t, new(AgentPublicTestSuite))
}
4 changes: 3 additions & 1 deletion internal/agent/condition_public_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,8 @@ func (s *ConditionPublicTestSuite) TestLastTransitionTimeTracking() {
}
}

func TestConditionPublicTestSuite(t *testing.T) {
func TestConditionPublicTestSuite(
t *testing.T,
) {
suite.Run(t, new(ConditionPublicTestSuite))
}
Loading
Loading