init go code

pull/3/head
sundowndev 2020-11-18 19:24:48 +01:00
parent 2bc024f29f
commit 2ff274452e
6 changed files with 63 additions and 20 deletions

View File

@ -1,26 +1,20 @@
name: Node.js tests name: Go
on: [ push ] on: [ push ]
jobs: jobs:
build: build:
name: Build
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
node-version: [8.x, 12.x]
steps: steps:
- uses: actions/checkout@v1 - name: Set up Go 1.15
- name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-go@v1
uses: actions/setup-node@v1
with: with:
node-version: ${{ matrix.node-version }} go-version: 1.15
id: go
- name: npm install and test - name: Check out code into the Go module directory
run: | uses: actions/checkout@v2
npm install
npm test - name: Test
env: run: go test -race -v -bench=. ./...
CI: true
NODE_ENV: test

2
.gitignore vendored
View File

@ -1 +1 @@
.idea

5
go.mod Normal file
View File

@ -0,0 +1,5 @@
module github.com/sundowndev/algorithms
go 1.15
require github.com/stretchr/testify v1.6.1

11
go.sum Normal file
View File

@ -0,0 +1,11 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

5
shuffle/shuffle.go Normal file
View File

@ -0,0 +1,5 @@
package shuffle
func shuffle(arr string) string {
return arr
}

28
shuffle/shuffle_test.go Normal file
View File

@ -0,0 +1,28 @@
package shuffle
import (
assertTest "github.com/stretchr/testify/assert"
"testing"
)
func TestShuffle(t *testing.T) {
assert := assertTest.New(t)
t.Run("should shuffle string", func(t *testing.T) {
payload := "my payload to shuffle"
assert.NotEqual(payload, shuffle(payload))
})
t.Run("should shuffle string", func(t *testing.T) {
payload := "a"
assert.Equal(payload, shuffle(payload))
})
t.Run("should shuffle string", func(t *testing.T) {
payload := "ab"
assert.Equal(payload, shuffle(payload))
})
}