(t *testing.T)
| 67 | } |
| 68 | |
| 69 | func TestExtractSecretsFromHeaders(t *testing.T) { |
| 70 | headers := map[string]string{ |
| 71 | "DD_API_KEY": "${{ secrets.DD_API_KEY }}", |
| 72 | "DD_APPLICATION_KEY": "${{ secrets.DD_APPLICATION_KEY }}", |
| 73 | "DD_SITE": "${{ secrets.DD_SITE || 'datadoghq.com' }}", |
| 74 | "Static": "no-secrets-here", |
| 75 | } |
| 76 | |
| 77 | result := ExtractSecretsFromMap(headers) |
| 78 | |
| 79 | expected := map[string]string{ |
| 80 | "DD_API_KEY": "${{ secrets.DD_API_KEY }}", |
| 81 | "DD_APPLICATION_KEY": "${{ secrets.DD_APPLICATION_KEY }}", |
| 82 | "DD_SITE": "${{ secrets.DD_SITE || 'datadoghq.com' }}", |
| 83 | } |
| 84 | |
| 85 | if len(result) != len(expected) { |
| 86 | t.Errorf("Expected %d secrets, got %d", len(expected), len(result)) |
| 87 | } |
| 88 | |
| 89 | for key, expectedValue := range expected { |
| 90 | if actualValue, exists := result[key]; !exists { |
| 91 | t.Errorf("Expected secret %s not found", key) |
| 92 | } else if actualValue != expectedValue { |
| 93 | t.Errorf("For key %s, expected %q, got %q", key, expectedValue, actualValue) |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | func TestReplaceSecretsWithEnvVars(t *testing.T) { |
| 99 | tests := []struct { |
nothing calls this directly
no test coverage detected