Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
"request": "launch",
"mode": "auto",
"program": "main.go"
},
{
"name": "Launch e2e tests",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "test",
"args": ["./e2e"]
}
]
}
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ run:

build:
go build -o bin/main main.go

test:
go test -v ./e2e/
13 changes: 13 additions & 0 deletions e2e/conduit_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package conduit

import (
"testing"
)

func TestProcessing(t *testing.T) {
describe("Processing", t)

// ch := make(chan conduit.Transformable, 3)
generateFiles("ingress", 3, "test-file")
// data := conduit.Extract(, ch)
}
82 changes: 82 additions & 0 deletions e2e/helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package conduit

import (
"encoding/json"
"fmt"
"strings"
"sync"
"testing"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
)

type TestStruct struct {
TestString string
TestInt int
TestBool bool
}

func expectEqualInts(value int, expectation int, t *testing.T) {
if value != expectation {
t.Errorf("Failed: expected %d, but found %d", value, expectation)
}
}

func expectEqualStrings(value string, expectation string, t *testing.T) {
if value != expectation {
t.Errorf("Failed: expected %s, but found %s", value, expectation)
}
}

func describe(functionName string, t *testing.T) {
t.Logf("%s:", functionName)
}

func it(description string, t *testing.T) {
t.Logf(" - it %s", description)
}

func context(description string, t *testing.T) {
t.Logf(" - when %s", description)
}

func generateFiles(bucket string, count int, filePrefix string) {
var wg sync.WaitGroup
sess := session.Must(session.NewSessionWithOptions(session.Options{
SharedConfigState: session.SharedConfigEnable,
Config: aws.Config{
S3ForcePathStyle: aws.Bool(true),
Region: aws.String("us-east-1"),
Endpoint: aws.String("http://localstack:4566"),
},
}))
uploader := s3manager.NewUploader(sess)

for i := 1; i <= count; i++ {
wg.Add(1)
go func(j int, uploader *s3manager.Uploader, filePrefix string) {
defer wg.Done()

data := TestStruct{
TestBool: j == 1,
TestString: "foo",
TestInt: j,
}
human_enc, err := json.Marshal(data)
if err != nil {
fmt.Println(err)
}

key := fmt.Sprintf("%s%d", filePrefix, j)
body := string(human_enc)
uploader.Upload(&s3manager.UploadInput{
Bucket: aws.String(bucket),
Key: aws.String(key),
Body: strings.NewReader(body),
})
}(i, uploader, filePrefix)
}
wg.Wait()
}