diff --git a/.github/workflows/test-go.yaml b/.github/workflows/test-go.yaml new file mode 100644 index 00000000..d9f92019 --- /dev/null +++ b/.github/workflows/test-go.yaml @@ -0,0 +1,38 @@ +name: Lint and Test golang + +on: + pull_request: + push: + branches: + - main + - develop + +jobs: + # golangci: + # name: lint + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - uses: actions/setup-go@v4 + # with: + # go-version: '1.21' + # cache: false + # - name: golangci-lint + # uses: golangci/golangci-lint-action@v3 + # with: + # version: v1.54 + test: + name: Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v4 + with: + go-version: '1.21' + - name: Test + run: | + go test -v ./... + - name: Build State manager + run: | + go build backend/state-manager/cmd/main.go + diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 00000000..e7189369 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,16 @@ +linters: + disable-all: true + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - typecheck + - unused + - gosec + - godot + - forbidigo + - gocritic + - revive + - gofmt diff --git a/backend/state-manager/pkg/db/db_test.go b/backend/state-manager/pkg/db/db_test.go index 59183621..16750b98 100644 --- a/backend/state-manager/pkg/db/db_test.go +++ b/backend/state-manager/pkg/db/db_test.go @@ -16,14 +16,14 @@ func Test_ConnectDB(t *testing.T) { Open() } -func Test_SetPoint(t *testing.T) { +func Test_UpdatePoint(t *testing.T) { defer C() err := godotenv.Load("../../cmd/.env") if err != nil { panic(err) } Open() - SetPoint(&statev1.PointAndState{ + UpdatePoint(&statev1.PointAndState{ Id: "test", State: statev1.PointStateEnum_POINT_STATE_REVERSE, }) @@ -36,14 +36,14 @@ func Test_SetPoint(t *testing.T) { } } -func Test_SetStop(t *testing.T) { +func Test_UpdateStop(t *testing.T) { defer C() err := godotenv.Load("../../cmd/.env") if err != nil { panic(err) } Open() - SetStop(&statev1.StopAndState{ + UpdateStop(&statev1.StopAndState{ Id: "test", State: statev1.StopStateEnum_STOP_STATE_GO, }) @@ -63,11 +63,11 @@ func Test_GetPoints(t *testing.T) { panic(err) } Open() - SetPoint(&statev1.PointAndState{ + UpdatePoint(&statev1.PointAndState{ Id: "test", State: statev1.PointStateEnum_POINT_STATE_REVERSE, }) - SetPoint(&statev1.PointAndState{ + UpdatePoint(&statev1.PointAndState{ Id: "test2", State: statev1.PointStateEnum_POINT_STATE_NORMAL, }) @@ -84,11 +84,11 @@ func Test_GetStops(t *testing.T) { panic(err) } Open() - SetStop(&statev1.StopAndState{ + UpdateStop(&statev1.StopAndState{ Id: "test", State: statev1.StopStateEnum_STOP_STATE_GO, }) - SetStop(&statev1.StopAndState{ + UpdateStop(&statev1.StopAndState{ Id: "test2", State: statev1.StopStateEnum_STOP_STATE_STOP, }) @@ -105,14 +105,14 @@ func Test_GetBlocks(t *testing.T) { panic(err) } Open() - err = SetBlock(&statev1.BlockState{ + err = UpdateBlock(&statev1.BlockState{ BlockId: "test", State: statev1.BlockStateEnum_BLOCK_STATE_OPEN, }) if err != nil { t.Fatal("error") } - err = SetBlock(&statev1.BlockState{ + err = UpdateBlock(&statev1.BlockState{ BlockId: "test2", State: statev1.BlockStateEnum_BLOCK_STATE_CLOSE, })