-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconnector_test.go
41 lines (34 loc) · 1.02 KB
/
connector_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package docker_test
import (
"context"
"encoding/json"
"io"
"strings"
"testing"
"go.arcalot.io/assert"
"go.arcalot.io/log/v2"
docker "go.flow.arcalot.io/dockerdeployer"
)
func TestSimpleInOut(t *testing.T) {
configJSON := `{}`
var config any
if err := json.Unmarshal([]byte(configJSON), &config); err != nil {
t.Fatal(err)
}
factory := docker.NewFactory()
schema := factory.ConfigurationSchema()
unserializedConfig, err := schema.UnserializeType(config)
assert.NoError(t, err)
connector, err := factory.Create(unserializedConfig, log.NewTestLogger(t))
assert.NoError(t, err)
container, err := connector.Deploy(context.Background(), "quay.io/joconnel/io-test-script")
assert.NoError(t, err)
t.Cleanup(func() {
assert.NoError(t, container.Close())
})
var containerInput = []byte("abc\n")
_ = assert.NoErrorR[int](t)(container.Write(containerInput))
buf := new(strings.Builder)
_ = assert.NoErrorR[int64](t)(io.Copy(buf, container))
assert.Contains(t, buf.String(), "This is what input was received: \"abc\"")
}