52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
package backup
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
ctesting "github.com/alcionai/corso/internal/testing"
|
|
)
|
|
|
|
type ExchangeSuite struct {
|
|
suite.Suite
|
|
}
|
|
|
|
func TestExchangeSuite(t *testing.T) {
|
|
suite.Run(t, new(ExchangeSuite))
|
|
}
|
|
|
|
func (suite *ExchangeSuite) TestAddExchangeCommands() {
|
|
expectUse := exchangeServiceCommand
|
|
table := []struct {
|
|
name string
|
|
use string
|
|
expectUse string
|
|
expectShort string
|
|
expectRunE func(*cobra.Command, []string) error
|
|
}{
|
|
{"create exchange", createCommand, expectUse, exchangeCreateCmd.Short, createExchangeCmd},
|
|
{"list exchange", listCommand, expectUse, exchangeListCmd.Short, listExchangeCmd},
|
|
{"details exchange", detailsCommand, expectUse, exchangeDetailsCmd.Short, detailsExchangeCmd},
|
|
}
|
|
for _, test := range table {
|
|
suite.T().Run(test.name, func(t *testing.T) {
|
|
cmd := &cobra.Command{Use: test.use}
|
|
|
|
c := addExchangeCommands(cmd)
|
|
require.NotNil(t, c)
|
|
|
|
cmds := cmd.Commands()
|
|
require.Len(t, cmds, 1)
|
|
|
|
child := cmds[0]
|
|
assert.Equal(t, test.expectUse, child.Use)
|
|
assert.Equal(t, test.expectShort, child.Short)
|
|
ctesting.AreSameFunc(t, test.expectRunE, child.RunE)
|
|
})
|
|
}
|
|
}
|