Files
Dominik Schulz 7281ca8ab4 [chore] Migrate to golangci-lint v2 (#3104)
* [chore] Migrate to golangci-lint v2

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* [chore] Fix more lint issues

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* [chore] Fix more lint issue

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* [chore] Fix more lint issues

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* [chore] Add more package comments.

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* [chore] Fix golangci-lint config and the remaining checks

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* [fix] Use Go 1.24

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* [fix] Fix container builds

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* Fix more failing tests

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* Fix test failure

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* Fix another len assertion

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* Move location tests

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* [fix] Fix most remaining lint issues

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* [fix] Only run XDG specific tests on linux

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* [fix] Attempt to address on source of flaky failures

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

---------

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
2025-04-17 08:05:43 +02:00

46 lines
845 B
Go

package age
import (
"testing"
)
func TestWithOnlyNative(t *testing.T) {
ctx := t.Context()
ctx = WithOnlyNative(ctx, true)
val := ctx.Value(ctxKeyOnlyNative)
if val == nil {
t.Errorf("Expected value to be set, got nil")
}
boolVal, ok := val.(bool)
if !ok {
t.Errorf("Expected value to be of type bool, got %T", val)
}
if !boolVal {
t.Errorf("Expected value to be true, got false")
}
}
func TestIsOnlyNative(t *testing.T) {
ctx := t.Context()
// Test default value
if IsOnlyNative(ctx) {
t.Errorf("Expected default value to be false, got true")
}
// Test set value
ctx = WithOnlyNative(ctx, true)
if !IsOnlyNative(ctx) {
t.Errorf("Expected value to be true, got false")
}
// Test reset value
ctx = WithOnlyNative(ctx, false)
if IsOnlyNative(ctx) {
t.Errorf("Expected value to be false, got true")
}
}