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
13 changes: 13 additions & 0 deletions services/opsworks/export_test.go
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
47 changes: 47 additions & 0 deletions services/opsworks/sdk_completeness_test.go
Original file line number Diff line number Diff line change
@@ -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.")
}
Loading