From 99c76e8970580f46ebc8113938bd6eb5f5b17651 Mon Sep 17 00:00:00 2001 From: jade Date: Fri, 12 Jun 2026 21:03:14 -0500 Subject: [PATCH] test(opsworks): add sdk_completeness_test without non-existent SDK v2 import OpsWorks was deprecated and not ported to aws-sdk-go-v2, so there is no aws-sdk-go-v2/service/opsworks package. Add sdk_completeness_test.go that verifies internal consistency (no duplicate ops, dispatch table matches GetSupportedOperations) instead of comparing against an SDK client. Export HandlerDispatchKeys via export_test.go to enable the comparison. Closes go-5uju --- services/opsworks/export_test.go | 13 ++++++ services/opsworks/sdk_completeness_test.go | 47 ++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 services/opsworks/sdk_completeness_test.go diff --git a/services/opsworks/export_test.go b/services/opsworks/export_test.go index 79395bb34..0820e0c6b 100644 --- a/services/opsworks/export_test.go +++ b/services/opsworks/export_test.go @@ -1,5 +1,18 @@ package opsworks +import "sort" + +// HandlerDispatchKeys returns the sorted operation keys from the handler's dispatch table. +func HandlerDispatchKeys(h *Handler) []string { + keys := make([]string, 0, len(h.ops)) + for k := range h.ops { + keys = append(keys, k) + } + sort.Strings(keys) + + return keys +} + // StackCount returns the number of stored stacks. func StackCount(b *InMemoryBackend) int { b.mu.RLock("StackCount") diff --git a/services/opsworks/sdk_completeness_test.go b/services/opsworks/sdk_completeness_test.go new file mode 100644 index 000000000..dbfe8fe68 --- /dev/null +++ b/services/opsworks/sdk_completeness_test.go @@ -0,0 +1,47 @@ +package opsworks_test + +// OpsWorks was not migrated to AWS SDK v2 — it was deprecated and removed from +// the SDK. There is no aws-sdk-go-v2/service/opsworks package to compare against. +// Instead, this file verifies internal consistency between GetSupportedOperations() +// and the handler dispatch table. + +import ( + "sort" + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/blackbirdworks/gopherstack/services/opsworks" +) + +// TestSDKCompleteness verifies that GetSupportedOperations() has no duplicates +// and matches the handler's internal dispatch table exactly. Because OpsWorks is +// not present in aws-sdk-go-v2, no SDK client comparison is performed. +func TestSDKCompleteness(t *testing.T) { + t.Parallel() + + backend := opsworks.NewInMemoryBackend("000000000000", "us-east-1") + h := opsworks.NewHandler(backend) + + supportedOps := h.GetSupportedOperations() + + seen := make(map[string]bool, len(supportedOps)) + var dups []string + + for _, op := range supportedOps { + if seen[op] { + dups = append(dups, op) + } + seen[op] = true + } + + assert.Empty(t, dups, "GetSupportedOperations() contains duplicate entries — remove the duplicates.") + + dispatchKeys := opsworks.HandlerDispatchKeys(h) + supported := make([]string, len(supportedOps)) + copy(supported, supportedOps) + sort.Strings(supported) + + assert.Equal(t, dispatchKeys, supported, + "GetSupportedOperations() and the dispatch table must contain exactly the same operations.") +}