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
5 changes: 4 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ jobs:
- run: go vet ./...
- uses: dominikh/staticcheck-action@v1
with: { install-go: false }
- run: go test -v ./...
- run: go test -v .
- run: go test -v -tags integration ./test
env:
UNSTRUCTURED_API_KEY: ${{ secrets.UNSTRUCTURED_API_KEY }}
18 changes: 18 additions & 0 deletions test/context_new_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//go:build go1.24 && integration

package test

import (
"context"
"crypto/rand"
"testing"
)

// textContext mimics [*testing.T.Context], which was added in go1.24.
func testContext(t *testing.T) context.Context {
return t.Context()
}

func randText() string {
return rand.Text()
}
27 changes: 27 additions & 0 deletions test/context_old_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//go:build !go1.24 && integration

package test

import (
"context"
"crypto/rand"
"testing"
)

// textContext mimics [*testing.T.Context], which was added in go1.24.
func testContext(t *testing.T) context.Context {
t.Helper()
ctx, cancel := context.WithCancel(context.Background())
t.Cleanup(cancel)
return ctx
}

func randText() string {
const base32 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"
src := make([]byte, 26)
rand.Read(src)
for i := range src {
src[i] = base32[src[i]%32]
}
return string(src)
}
3 changes: 1 addition & 2 deletions test/destination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package test

import (
"context"
"crypto/rand"
"fmt"
"os"
"testing"
Expand Down Expand Up @@ -201,7 +200,7 @@ func TestDestinationPermutations(t *testing.T) {
t.Parallel()

destination, err := client.CreateDestination(testContext(t), unstructured.CreateDestinationRequest{
Name: fmt.Sprintf("test-%s-%s", name, rand.Text()),
Name: fmt.Sprintf("test-%s-%s", name, randText()),
Config: src,
})
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions test/source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package test

import (
"context"
"crypto/rand"
"fmt"
"os"
"testing"
Expand Down Expand Up @@ -187,7 +186,7 @@ func TestSourcePermutations(t *testing.T) {
t.Parallel()

source, err := client.CreateSource(testContext(t), unstructured.CreateSourceRequest{
Name: fmt.Sprintf("test-%s-%s", name, rand.Text()),
Name: fmt.Sprintf("test-%s-%s", name, randText()),
Config: src,
})
if err != nil {
Expand Down