Skip to content

Commit

Permalink
Add integration tests to workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
eleven26 committed Apr 4, 2023
1 parent a4e8da3 commit f50a3a4
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
33 changes: 32 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:

build:
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -25,3 +25,34 @@ jobs:
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml

integration-test:
runs-on: ubuntu-latest
needs: unit-test
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18

- name: Start UP MinIO
uses: infleet/[email protected]
with:
port: "9000"
version: "latest"
username: ${{ secrets.MINIO_SERVER_ACCESS_KEY }}
password: ${{ secrets.MINIO_SERVER_SECRET_KEY }}

- name: Create .goss.yml
env:
GOSS_YML: ${{ secrets.GOSS_YML }}
run: |
cat <<EOF > ~/.goss.yml
$GOSS_YML
EOF
- name: Integration Test
run: |
make integration
9 changes: 8 additions & 1 deletion drivers/minio/minio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ func init() {
testdata = filepath.Join(utils.RootDir(), "testdata")
fooPath = filepath.Join(testdata, "foo.txt")
localFooPath = filepath.Join(testdata, "foo1.txt")

err = store.CreateBucketIfNotExists()
if err != nil {
log.Fatal(err)
}
}

func setUp(t *testing.T) {
Expand Down Expand Up @@ -216,7 +221,7 @@ func TestFiles(t *testing.T) {
assert.Equal(t, today, files[0].LastModified().Format("2006-01-02"))
}

func aTestAb(t *testing.T) {
func putFiles(t *testing.T) {
dir := "test_all/"

for i := 1; i <= 200; i++ {
Expand All @@ -226,6 +231,8 @@ func aTestAb(t *testing.T) {
}

func TestFilesWithMultiPage(t *testing.T) {
putFiles(t)

// Testdata was prepared before.
dir := "test_all/"

Expand Down
13 changes: 13 additions & 0 deletions drivers/minio/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ func (s *Store) Put(key string, r io.Reader) error {
return err
}

func (s *Store) CreateBucketIfNotExists() error {
exists, err := s.client.BucketExists(context.Background(), s.config.Bucket)
if err != nil {
return err
}

if !exists {
return s.client.MakeBucket(context.Background(), s.config.Bucket, minio.MakeBucketOptions{})
}

return nil
}

func (s *Store) putFile(key string, f *os.File) error {
fi, err := f.Stat()
if err != nil {
Expand Down

0 comments on commit f50a3a4

Please sign in to comment.