Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow for case-insensitve matching of products #458

Merged
merged 1 commit into from
Jun 8, 2024
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
10 changes: 10 additions & 0 deletions lib/product_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ func Test_GetProductById(t *testing.T) {
}
}

// Test case-insensitve match
product = GetProductById("oPeNtOfU")
if product == nil {
t.Errorf("Terraform product returned nil")
} else {
if expected := "opentofu"; product.GetId() != expected {
t.Errorf("Product ID does not match expected Id. Expected: %q, actual: %q", expected, product.GetId())
}
}

product = GetProductById("doesnotexist")
if product != nil {
t.Errorf("Unknown product returned non-nil response")
Expand Down
2 changes: 1 addition & 1 deletion lib/products.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ var products = []Product{

func GetProductById(id string) Product {
for _, product := range products {
if product.GetId() == id {
if strings.EqualFold(product.GetId(), id) {
return product
}
}
Expand Down