mirror of
https://github.com/neilotoole/sq.git
synced 2024-12-18 13:41:49 +03:00
ed9aa38a67
* Expose source.Set.Data() method * jsonw.writeJSON cleaned up * sq add now respects --json * Location strings are subject to more scrutiny * Ignore .db files in project dir * sq add is more restrictive about location string * source.RedactedLocation now uses 'xxxxx' per stdlib url.URL.Redacted() * Update changelog for v0.23.0 * typos
35 lines
753 B
Go
35 lines
753 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)
|
|
err := ru.Exec("rm", "@not_a_source")
|
|
require.Error(t, err)
|
|
|
|
// 2. Check normal operation
|
|
src := th.Source(sakila.SL3)
|
|
ru = newRun(t).add(*src)
|
|
|
|
// The src we just added should be the active src
|
|
activeSrc := ru.rc.Config.Sources.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.Sources.Active()
|
|
require.Nil(t, activeSrc, "should be no active src anymore")
|
|
}
|