Skip to content
Merged
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
41 changes: 40 additions & 1 deletion app/controlplane/internal/service/attestation_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2023 The Chainloop Authors.
// Copyright 2023-2026 The Chainloop Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -99,3 +99,42 @@ func TestExtractMaterials(t *testing.T) {
})
}
}

func TestExtractEnvVariables(t *testing.T) {
testCases := []struct {
name string
input map[string]string
want []*cpAPI.AttestationItem_EnvVariable
}{
{
name: "returns env vars sorted by name",
input: map[string]string{
"Z_VAR": "z",
"A_VAR": "a",
"M_VAR": "m",
},
want: []*cpAPI.AttestationItem_EnvVariable{
{Name: "A_VAR", Value: "a"},
{Name: "M_VAR", Value: "m"},
{Name: "Z_VAR", Value: "z"},
},
},
{
name: "empty input",
input: map[string]string{},
want: []*cpAPI.AttestationItem_EnvVariable{},
},
{
name: "nil input",
input: nil,
want: []*cpAPI.AttestationItem_EnvVariable{},
},
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
got := extractEnvVariables(tc.input)
assert.Equal(t, tc.want, got)
})
}
}
Loading