mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-15 15:28:04 +00:00
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
```
47 lines
1,014 B
Go
47 lines
1,014 B
Go
package ctl
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"io"
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/molecula/featurebase/v2/testhook"
|
|
)
|
|
|
|
func TestInspectCommand_Run(t *testing.T) {
|
|
rder := []byte{}
|
|
stdin := bytes.NewReader(rder)
|
|
r, w, _ := os.Pipe()
|
|
|
|
cm := NewInspectCommand(stdin, w, w)
|
|
file, err := testhook.TempFile(t, "inspectTest")
|
|
if err != nil {
|
|
t.Fatalf("Error creating tempfile: %s", err)
|
|
}
|
|
_, err = file.Write([]byte("12358267538963"))
|
|
if err != nil {
|
|
t.Fatalf("writing to tempfile: %v", err)
|
|
}
|
|
file.Close()
|
|
cm.Path = file.Name()
|
|
err = cm.Run(context.Background())
|
|
expectedError := "inspecting: "
|
|
if !strings.Contains(err.Error(), expectedError) {
|
|
t.Fatalf("expected error '%s', got '%v'", expectedError, err)
|
|
}
|
|
|
|
w.Close()
|
|
var buf bytes.Buffer
|
|
_, err = io.Copy(&buf, r)
|
|
if err != nil {
|
|
t.Fatalf("copying data: %v", err)
|
|
}
|
|
if !strings.Contains(buf.String(), "inspecting bitmap...") {
|
|
t.Fatalf("Inspect doesn't work: %s", err)
|
|
}
|
|
|
|
// Todo: need correct roaring file for happy path
|
|
}
|