29 lines
606 B
Go
29 lines
606 B
Go
package trim
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"gitea.maximumdirect.net/eric/seriatim/internal/config"
|
|
)
|
|
|
|
func TestRunReturnsContextErrorBeforeWork(t *testing.T) {
|
|
dir := t.TempDir()
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
cancel()
|
|
|
|
err := Run(ctx, config.TrimConfig{
|
|
InputFile: filepath.Join(dir, "input.json"),
|
|
OutputFile: filepath.Join(dir, "output.json"),
|
|
Mode: "keep",
|
|
Selector: "1",
|
|
OutputSchema: "",
|
|
AllowEmpty: false,
|
|
})
|
|
if !errors.Is(err, context.Canceled) {
|
|
t.Fatalf("error = %v, want context.Canceled", err)
|
|
}
|
|
}
|