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
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package cmd

import (
"testing"

"github.com/stretchr/testify/assert"
)

// ─── boolStr ─────────────────────────────────────────────────────────────────

func TestBoolStr(t *testing.T) {
t.Parallel()
tests := []struct {
name string
val *bool
want string
}{
{"nil", nil, "unknown"},
{"true", new(true), "true"},
{"false", new(false), "false"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
assert.Equal(t, tt.want, boolStr(tt.val))
})
}
}

// ─── sortedKeys ──────────────────────────────────────────────────────────────

func TestSortedKeys(t *testing.T) {
t.Parallel()
tests := []struct {
name string
m map[string]int
want []string
}{
{"nil map", nil, nil},
{"empty map", map[string]int{}, nil},
{"single", map[string]int{"a": 1}, []string{"a"}},
{"multiple", map[string]int{"c": 3, "a": 1, "b": 2}, []string{"a", "b", "c"}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
got := sortedKeys(tt.m)
assert.Equal(t, tt.want, got)
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ To change the trigger or action type, delete and recreate the routine.`,
"Not allowed on update: trigger types are immutable. Delete and recreate to change.")
cmd.Flags().StringVar(&flags.action, "action", "",
"Not allowed on update: action types are immutable. Delete and recreate to change.")
// Safe to ignore: flags are registered immediately above, so MarkHidden cannot fail.
_ = cmd.Flags().MarkHidden("trigger")
_ = cmd.Flags().MarkHidden("action")

Expand Down
Loading
Loading