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
26 changes: 10 additions & 16 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
name: CI

on:
push:
branches: [ main ]
paths:
- '**/*.go'
- 'go.mod'
- 'go.sum'
- '.github/workflows/ci.yaml'
pull_request:
branches: [ main ]
paths:
Expand All @@ -19,15 +12,16 @@ on:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.23', '1.24', '1.25' ]
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Install dependencies
run: |
go get .
- name: Run tests
run: go test -race -v ./...
go-version: ${{ matrix.go-version }}
- run: go mod download
- run: go vet ./...
- uses: dominikh/staticcheck-action@v1
with: { install-go: false }
- run: go test -v ./...
13 changes: 13 additions & 0 deletions context_new_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//go:build go1.24

package unstructured

import (
"context"
"testing"
)

// textContext mimics [*testing.T.Context], which was added in go1.24.
func testContext(t *testing.T) context.Context {
return t.Context()
}
16 changes: 16 additions & 0 deletions context_old_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//go:build !go1.24

package unstructured

import (
"context"
"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
}
2 changes: 1 addition & 1 deletion destination_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestCreateDestination(t *testing.T) {
w.Write(response)
}

destination, err := client.CreateDestination(t.Context(), CreateDestinationRequest{
destination, err := client.CreateDestination(testContext(t), CreateDestinationRequest{
Name: "test_destination_name",

Config: &S3ConnectorConfig{
Expand Down
2 changes: 1 addition & 1 deletion destination_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestDeleteDestination(t *testing.T) {
w.Write(response)
}

err := client.DeleteDestination(t.Context(), "b25d4161-77a0-4e08-b65e-86f398ce15ad")
err := client.DeleteDestination(testContext(t), "b25d4161-77a0-4e08-b65e-86f398ce15ad")
if err != nil {
t.Fatalf("failed to delete destination: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions destination_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestGetDestination(t *testing.T) {
w.Write(response)
}

destination, err := client.GetDestination(t.Context(), id)
destination, err := client.GetDestination(testContext(t), id)
if err != nil {
t.Fatalf("failed to get destination: %v", err)
}
Expand Down Expand Up @@ -70,7 +70,7 @@ func TestGetDestinationNotFound(t *testing.T) {
http.Error(w, "destination ID "+r.PathValue("id")+" not found", http.StatusNotFound)
}

_, err := client.GetDestination(t.Context(), id)
_, err := client.GetDestination(testContext(t), id)
if err == nil {
t.Fatalf("expected error, got nil")
}
Expand Down
6 changes: 3 additions & 3 deletions destination_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestListDestinations(t *testing.T) {
w.Write(response)
}

destinations, err := client.ListDestinations(t.Context(), "")
destinations, err := client.ListDestinations(testContext(t), "")
if err != nil {
t.Fatalf("failed to list destinations: %v", err)
}
Expand Down Expand Up @@ -74,7 +74,7 @@ func TestListDestinationsEmpty(t *testing.T) {
w.Write([]byte("[]"))
}

destinations, err := client.ListDestinations(t.Context(), "")
destinations, err := client.ListDestinations(testContext(t), "")
if err != nil {
t.Fatalf("failed to list destinations: %v", err)
}
Expand Down Expand Up @@ -107,7 +107,7 @@ func TestListDestinationsErrorCode(t *testing.T) {
w.WriteHeader(code)
}

_, err := client.ListDestinations(t.Context(), "")
_, err := client.ListDestinations(testContext(t), "")
if err == nil {
t.Fatalf("expected error, got nil")
}
Expand Down
2 changes: 1 addition & 1 deletion destination_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestUpdateDestination(t *testing.T) {
w.Write(response)
}

updated, err := client.UpdateDestination(t.Context(), UpdateDestinationRequest{
updated, err := client.UpdateDestination(testContext(t), UpdateDestinationRequest{
ID: id,
Config: &S3ConnectorConfig{
RemoteURL: "s3://mock-s3-connector",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/aws-gopher/unstructured-sdk-go

go 1.25.0
go 1.23
2 changes: 1 addition & 1 deletion job_cancel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestCancelJob(t *testing.T) {
w.Write(response)
}

err := client.CancelJob(t.Context(), id)
err := client.CancelJob(testContext(t), id)
if err != nil {
t.Fatalf("failed to cancel job: %v", err)
}
Expand Down
6 changes: 3 additions & 3 deletions job_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestGetJob(t *testing.T) {
w.Write(response)
}

job, err := client.GetJob(t.Context(), id)
job, err := client.GetJob(testContext(t), id)
if err != nil {
t.Fatalf("failed to get job: %v", err)
}
Expand All @@ -62,7 +62,7 @@ func TestGetJobNotFound(t *testing.T) {
http.Error(w, "job ID "+r.PathValue("id")+" not found", http.StatusNotFound)
}

_, err := client.GetJob(t.Context(), id)
_, err := client.GetJob(testContext(t), id)
if err == nil {
t.Fatalf("expected error, got nil")
}
Expand Down Expand Up @@ -102,7 +102,7 @@ func TestGetJobError(t *testing.T) {
w.WriteHeader(code)
}

_, err := client.GetJob(t.Context(), id)
_, err := client.GetJob(testContext(t), id)
if err == nil {
t.Fatalf("expected error, got nil")
}
Expand Down
2 changes: 1 addition & 1 deletion jobs_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestListJobs(t *testing.T) {
w.Write(response)
}

jobs, err := client.ListJobs(t.Context(), &ListJobsRequest{})
jobs, err := client.ListJobs(testContext(t), &ListJobsRequest{})
if err != nil {
t.Fatalf("failed to list jobs: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion source_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestCreateSource(t *testing.T) {
w.Write(response)
}

source, err := client.CreateSource(t.Context(), CreateSourceRequest{
source, err := client.CreateSource(testContext(t), CreateSourceRequest{
Name: "test_source_name",
Config: &OneDriveConnectorConfig{
ClientID: "foo",
Expand Down
2 changes: 1 addition & 1 deletion source_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestDeleteSource(t *testing.T) {
w.Write(response)
}

err := client.DeleteSource(t.Context(), id)
err := client.DeleteSource(testContext(t), id)
if err != nil {
t.Fatalf("failed to delete source: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions source_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestGetSource(t *testing.T) {
w.Write(response)
}

source, err := client.GetSource(t.Context(), id)
source, err := client.GetSource(testContext(t), id)
if err != nil {
t.Fatalf("failed to get source: %v", err)
}
Expand Down Expand Up @@ -70,7 +70,7 @@ func TestGetSourceNotFound(t *testing.T) {
http.Error(w, "source ID "+r.PathValue("id")+" not found", http.StatusNotFound)
}

_, err := client.GetSource(t.Context(), id)
_, err := client.GetSource(testContext(t), id)
if err == nil {
t.Fatalf("expected error, got nil")
}
Expand Down
6 changes: 3 additions & 3 deletions source_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestListSources(t *testing.T) {
w.Write(response)
}

sources, err := client.ListSources(t.Context(), "")
sources, err := client.ListSources(testContext(t), "")
if err != nil {
t.Fatalf("failed to list sources: %v", err)
}
Expand Down Expand Up @@ -75,7 +75,7 @@ func TestListSourcesEmpty(t *testing.T) {
w.Write(response)
}

sources, err := client.ListSources(t.Context(), "")
sources, err := client.ListSources(testContext(t), "")
if err != nil {
t.Fatalf("failed to list sources: %v", err)
}
Expand Down Expand Up @@ -108,7 +108,7 @@ func TestListSourcesErrorCode(t *testing.T) {
w.WriteHeader(code)
}

_, err := client.ListSources(t.Context(), "")
_, err := client.ListSources(testContext(t), "")
if err == nil {
t.Fatalf("expected error, got nil")
}
Expand Down
2 changes: 1 addition & 1 deletion source_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestUpdateSource(t *testing.T) {
w.Write(response)
}

source, err := client.UpdateSource(t.Context(), UpdateSourceRequest{
source, err := client.UpdateSource(testContext(t), UpdateSourceRequest{
ID: id,
Config: &OneDriveConnectorConfig{
ClientID: "foo",
Expand Down
2 changes: 1 addition & 1 deletion test/destination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func TestDestinationPermutations(t *testing.T) {
t.Run(name, func(t *testing.T) {
t.Parallel()

destination, err := client.CreateDestination(t.Context(), unstructured.CreateDestinationRequest{
destination, err := client.CreateDestination(testContext(t), unstructured.CreateDestinationRequest{
Name: fmt.Sprintf("test-%s-%s", name, rand.Text()),
Config: src,
})
Expand Down
2 changes: 1 addition & 1 deletion test/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestWorkflow(t *testing.T) {
t.Fatalf("failed to create client: %v", err)
}

ctx := t.Context()
ctx := testContext(t)

workflow, err := client.CreateWorkflow(ctx, &unstructured.CreateWorkflowRequest{
Name: "test",
Expand Down
2 changes: 1 addition & 1 deletion test/source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func TestSourcePermutations(t *testing.T) {
t.Run(name, func(t *testing.T) {
t.Parallel()

source, err := client.CreateSource(t.Context(), unstructured.CreateSourceRequest{
source, err := client.CreateSource(testContext(t), unstructured.CreateSourceRequest{
Name: fmt.Sprintf("test-%s-%s", name, rand.Text()),
Config: src,
})
Expand Down
2 changes: 1 addition & 1 deletion workflow_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestCreateWorkflow(t *testing.T) {
w.Write(response)
}

workflow, err := client.CreateWorkflow(t.Context(), &CreateWorkflowRequest{
workflow, err := client.CreateWorkflow(testContext(t), &CreateWorkflowRequest{
Name: "test_workflow",
Schedule: String("weekly"),
SourceID: String("f1f7b1b2-8e4b-4a2b-8f1d-3e3c7c9e5a3c"),
Expand Down
6 changes: 3 additions & 3 deletions workflow_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestListWorkflows(t *testing.T) {
w.Write(response)
}

workflows, err := client.ListWorkflows(t.Context(), &ListWorkflowsRequest{
workflows, err := client.ListWorkflows(testContext(t), &ListWorkflowsRequest{
SortBy: String("id"),
})
if err != nil {
Expand Down Expand Up @@ -73,7 +73,7 @@ func TestListWorkflowsEmpty(t *testing.T) {
w.Write(response)
}

workflows, err := client.ListWorkflows(t.Context(), &ListWorkflowsRequest{
workflows, err := client.ListWorkflows(testContext(t), &ListWorkflowsRequest{
SortBy: String("id"),
})
if err != nil {
Expand Down Expand Up @@ -108,7 +108,7 @@ func TestListWorkflowsErrorCode(t *testing.T) {
w.WriteHeader(code)
}

_, err := client.ListWorkflows(t.Context(), &ListWorkflowsRequest{
_, err := client.ListWorkflows(testContext(t), &ListWorkflowsRequest{
SortBy: String("id"),
})
if err == nil {
Expand Down
2 changes: 1 addition & 1 deletion workflow_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestRunWorkflow(t *testing.T) {
w.Write(response)
}

job, err := client.RunWorkflow(t.Context(), &RunWorkflowRequest{ID: id})
job, err := client.RunWorkflow(testContext(t), &RunWorkflowRequest{ID: id})
if err != nil {
t.Fatalf("failed to run workflow: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion workflow_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestUpdateWorkflow(t *testing.T) {
w.Write(response)
}

updated, err := client.UpdateWorkflow(t.Context(), UpdateWorkflowRequest{
updated, err := client.UpdateWorkflow(testContext(t), UpdateWorkflowRequest{
ID: id,
Name: String("test_workflow"),
WorkflowType: Ptr(WorkflowTypeAdvanced),
Expand Down