Denis Bilenko
1b2be1b2cb
Add error checking in tests and enable errcheck there ( #1980 )
...
## Changes
Fix all errcheck-found issues in tests and test helpers. Mostly this
done by adding require.NoError(t, err), sometimes panic() where t object
is not available).
Initial change is obtained with aider+claude, then manually reviewed and
cleaned up.
## Tests
Existing tests.
2024-12-09 13:56:41 +01:00
Serge Smertin
f111b0846e
Added process stubbing for easier testing of launched subprocesses ( #963 )
...
## Changes
This PR makes unit testing with subprocesses fast.
```
ctx := context.Background()
ctx, stub := process.WithStub(ctx)
stub.WithDefaultOutput("meeee")
ctx = env.Set(ctx, "FOO", "bar")
out, err := process.Background(ctx, []string{"/usr/local/bin/meeecho", "1", "--foo", "bar"})
require.NoError(t, err)
require.Equal(t, "meeee", out)
require.Equal(t, 1, stub.Len())
require.Equal(t, []string{"meeecho 1 --foo bar"}, stub.Commands())
allEnv := stub.CombinedEnvironment()
require.Equal(t, "bar", allEnv["FOO"])
require.Equal(t, "bar", stub.LookupEnv("FOO"))
```
This should make further iterations of
https://github.com/databricks/cli/pull/914 easier
## Tests
`make test`
2023-11-09 14:24:05 +00:00