corso/src/cli/restore/onedrive_test.go
Keepers 78632f56e7
remove --all flag support, minor cleanup (#1047)
## Description

Removes the -all flag from the exchange cli.  The
same functionality can be gained with the flag
--user *.

Additionally does some minor tidying of other
comments and outputs throughout the cli.

## Type of change

- [x] 🐹 Trivial/Minor

## Issue(s)

* #1032

## Test Plan

- [x]  Unit test
2022-10-06 00:10:56 +00:00

51 lines
1.1 KiB
Go

package restore
import (
"testing"
"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/alcionai/corso/src/internal/tester"
)
type OneDriveSuite struct {
suite.Suite
}
func TestOneDriveSuite(t *testing.T) {
suite.Run(t, new(OneDriveSuite))
}
func (suite *OneDriveSuite) TestAddOneDriveCommands() {
expectUse := oneDriveServiceCommand + " " + oneDriveServiceCommandUseSuffix
table := []struct {
name string
use string
expectUse string
expectShort string
expectRunE func(*cobra.Command, []string) error
}{
{"restore onedrive", restoreCommand, expectUse, oneDriveRestoreCmd().Short, restoreOneDriveCmd},
}
for _, test := range table {
suite.T().Run(test.name, func(t *testing.T) {
cmd := &cobra.Command{Use: test.use}
c := addOneDriveCommands(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)
tester.AreSameFunc(t, test.expectRunE, child.RunE)
})
}
}