mirror of
https://github.com/neilotoole/sq.git
synced 2024-12-18 21:52:28 +03:00
98b47a2666
* refactor: moved cli flags to pkg cli/flag * testh: add OptLongDB for long-running tests * implement 'sq config dir' * legacy dir migration: probably a bad idea * cleanup * Refactored SQ_CONFIG and --config * added yaml writer * Dialing in tests * YAML output for 'sq driver ls' * Significant refactoring of config * Minor test for ioz * Rename source.Set to source.Collection * Cleaning up references to source.Set
35 lines
769 B
Go
35 lines
769 B
Go
package cli_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/neilotoole/sq/testh"
|
|
"github.com/neilotoole/sq/testh/sakila"
|
|
)
|
|
|
|
func TestCmdRemove(t *testing.T) {
|
|
th := testh.New(t)
|
|
|
|
// 1. Should fail if bad handle
|
|
ru := newRun(t, nil)
|
|
err := ru.Exec("rm", "@not_a_source")
|
|
require.Error(t, err)
|
|
|
|
// 2. Check normal operation
|
|
src := th.Source(sakila.SL3)
|
|
ru = newRun(t, nil).add(*src)
|
|
|
|
// The src we just added should be the active src
|
|
activeSrc := ru.rc.Config.Collection.Active()
|
|
require.NotNil(t, activeSrc)
|
|
require.Equal(t, src.Handle, activeSrc.Handle)
|
|
|
|
err = ru.Exec("rm", src.Handle)
|
|
require.NoError(t, err)
|
|
|
|
activeSrc = ru.rc.Config.Collection.Active()
|
|
require.Nil(t, activeSrc, "should be no active src anymore")
|
|
}
|