featurebase/cmd/export_test.go
reesporte 4c53f86e82 removed license from each go file
i used this script, a little clunky but it got the job done

```bash
for file in `find . -type f -print | grep '\.go'`; do
    sed '1,/^\/\/ limitations under the License.$/d' $file > $file.tmp;
    result=`cat $file.tmp`
    if [[ result != "" ]]; then
        gofmt $file.tmp &> /dev/null;
        if [[ $? == 0 ]]; then
            mv $file.tmp $file && gofmt -w $file;
        else
            rm $file.tmp;
        fi
    else
        rm $file.tmp;
    fi
done
```
2021-12-10 09:17:17 -06:00

39 lines
961 B
Go

package cmd_test
import (
"strings"
"testing"
"github.com/molecula/featurebase/v2/cmd"
)
func TestExportHelp(t *testing.T) {
output, err := ExecNewRootCommand(t, "export", "--help")
if !strings.Contains(output, "Usage:") ||
!strings.Contains(output, "Flags:") ||
!strings.Contains(output, "featurebase export") || err != nil {
t.Fatalf("Command 'export --help' not working, err: '%v', output: '%s'", err, output)
}
}
func TestExportConfig(t *testing.T) {
tests := []commandTest{
{
args: []string{"export", "--output-file", "/somefile"},
env: map[string]string{"PILOSA_HOST": "localhost:12345"},
cfgFileContent: `
index = "myindex"
field = "f1"
`,
validation: func() error {
v := validator{}
v.Check(cmd.Exporter.Host, "localhost:12345")
v.Check(cmd.Exporter.Index, "myindex")
v.Check(cmd.Exporter.Field, "f1")
v.Check(cmd.Exporter.Path, "/somefile")
return v.Error()
},
},
}
executeDry(t, tests)
}