-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Project import generated by Copybara.
GitOrigin-RevId: 6f3c95ae2657a15c02e0a8be73395cdb7b330771
- Loading branch information
Copybara
committed
Feb 6, 2025
1 parent
476f6df
commit f4bf5d2
Showing
7 changed files
with
197 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package cmd | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/overmindtech/cli/sdp-go" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetTagsLine(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
tags map[string]*sdp.TagValue | ||
want string | ||
}{ | ||
{ | ||
name: "empty tags", | ||
tags: map[string]*sdp.TagValue{}, | ||
want: "", | ||
}, | ||
{ | ||
name: "key only", | ||
tags: map[string]*sdp.TagValue{ | ||
"key": {}, | ||
}, | ||
want: "`key` ", | ||
}, | ||
{ | ||
name: "auto tag without value", | ||
tags: map[string]*sdp.TagValue{ | ||
"autoTag": { | ||
Value: &sdp.TagValue_AutoTagValue{ | ||
AutoTagValue: &sdp.AutoTagValue{}, | ||
}, | ||
}, | ||
}, | ||
want: "`✨autoTag` ", | ||
}, | ||
{ | ||
name: "auto tag with value", | ||
tags: map[string]*sdp.TagValue{ | ||
"autoTag": { | ||
Value: &sdp.TagValue_AutoTagValue{ | ||
AutoTagValue: &sdp.AutoTagValue{ | ||
Value: "value", | ||
}, | ||
}, | ||
}, | ||
}, | ||
want: "`✨autoTag|value` ", | ||
}, | ||
{ | ||
name: "user tag without value", | ||
tags: map[string]*sdp.TagValue{ | ||
"userTag": { | ||
Value: &sdp.TagValue_UserTagValue{ | ||
UserTagValue: &sdp.UserTagValue{}, | ||
}, | ||
}, | ||
}, | ||
want: "`userTag` ", | ||
}, | ||
{ | ||
name: "user tag with value", | ||
tags: map[string]*sdp.TagValue{ | ||
"userTag": { | ||
Value: &sdp.TagValue_UserTagValue{ | ||
UserTagValue: &sdp.UserTagValue{ | ||
Value: "value", | ||
}, | ||
}, | ||
}, | ||
}, | ||
want: "`userTag|value` ", | ||
}, | ||
{ | ||
name: "mixed tags", | ||
tags: map[string]*sdp.TagValue{ | ||
"autoTag": { | ||
Value: &sdp.TagValue_AutoTagValue{ | ||
AutoTagValue: &sdp.AutoTagValue{ | ||
Value: "value", | ||
}, | ||
}, | ||
}, | ||
"userTag": { | ||
Value: &sdp.TagValue_UserTagValue{ | ||
UserTagValue: &sdp.UserTagValue{ | ||
Value: "value", | ||
}, | ||
}, | ||
}, | ||
}, | ||
want: "`✨autoTag|value` `userTag|value` ", | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got := getTagsLine(tt.tags) | ||
assert.Equal(t, tt.want, got) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters