Skip to content

Commit

Permalink
Merge pull request #16 from RyaWcksn/master
Browse files Browse the repository at this point in the history
feat(ci): Add release note
  • Loading branch information
RyaWcksn authored Oct 27, 2023
2 parents ef404e3 + 7f2935f commit 64f5211
Show file tree
Hide file tree
Showing 4 changed files with 286 additions and 30 deletions.
1 change: 1 addition & 0 deletions .#check_coverage.sh
37 changes: 26 additions & 11 deletions .github/workflows/runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Go

on:
push:
branches: [ "master" ]
branches: [ "release/*" ]

jobs:

Expand Down Expand Up @@ -57,23 +57,38 @@ jobs:
file: ./cov.txt
fail_ci_if_error: false

- name: Run tests and calculate coverage
run: |
go test ./... -coverprofile=coverage.out
go tool cover -func=coverage.out > coverage.txt
shell: bash

- name: Check coverage
run: ./check_coverage.sh
shell: bash

# - name: Run tests and calculate coverage
# run: |
# go test ./... -coverprofile=coverage.out
# go tool cover -func=coverage.out > coverage.txt
# shell: bash

# - name: Check coverage
# run: ./check_coverage.sh
# shell: bash

- name: Release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Generate Release Notes
run: |
VERSION=$(npx semantic-release-cli version)
echo "# Release Notes v.${VERSION}" > "v.${VERSION}.md"
npx semantic-release-cli changelog >> "v.${VERSION}.md"
echo "Release version: $VERSION" >> "v.${VERSION}.md"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Commit and Push Release Notes
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git add "v.${VERSION}.md"
git commit -m "chore(release): v.${{ steps.release.outputs.version }} release notes [skip ci]"
git push
docker:
runs-on: ubuntu-latest
steps:
Expand Down
62 changes: 43 additions & 19 deletions apis/v1/services/service_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ import (

func TestServiceImpl_Login(t *testing.T) {

ctrl := gomock.NewController(t)
defer ctrl.Finish()
// ctrl := gomock.NewController(t)
// defer ctrl.Finish()

buyerMock := repositories.NewMockIBuyer(ctrl)
sellerMock := repositories.NewMockISeller(ctrl)
productMock := repositories.NewMockIProduct(ctrl)
orderMock := repositories.NewMockIOrder(ctrl)
// buyerMock := repositories.NewMockIBuyer(ctrl)
cfg := configs.Cfg
log := logger.New("", "", "")

Expand All @@ -40,39 +37,66 @@ func TestServiceImpl_Login(t *testing.T) {
tests := []struct {
name string
args args
WantMock func()
WantMock func(ctrl *gomock.Controller) repositories.IBuyer
wantErr bool
}{
// {
// name: "Success",
// args: args{
// ctx: context.Background(),
// payload: &dto.LoginRequest{
// Email: "[email protected]",
// Password: "password123",
// Role: "buyer",
// },
// },
// WantMock: func() {
// buyerMock.EXPECT().GetEmail(gomock.Any(), gomock.Any()).Return(
// &entities.LoginEntity{
// Email: "[email protected]",
// Password: "$2a$10$xCniCdjZENytpQ7/NTNQduSJaZ6pl3bFMbd7bfF4OLwwbCyhGH8rC"},
// nil)
// },

// wantErr: false,
// },
{
name: "Success",
name: "Test",
args: args{
ctx: context.Background(),
ctx: context.TODO(),
payload: &dto.LoginRequest{
Email: "[email protected]",
Password: "password123",
Role: "buyer",
},
},
WantMock: func() {
buyerMock.EXPECT().GetEmail(gomock.Any(), gomock.Any()).Return(
&entities.LoginEntity{
Email: "[email protected]",
Password: "$2a$10$xCniCdjZENytpQ7/NTNQduSJaZ6pl3bFMbd7bfF4OLwwbCyhGH8rC"},
nil)
WantMock: func(ctrl *gomock.Controller) repositories.IBuyer {
mockData := repositories.NewMockIBuyer(ctrl)
mockData.EXPECT().GetEmail(gomock.Any(), gomock.Any()).Return(&entities.LoginEntity{
Email: "[email protected]",
Password: "$2a$10$xCniCdjZENytpQ7/NTNQduSJaZ6pl3bFMbd7bfF4OLwwbCyhGH8rC"},
nil).AnyTimes()
return mockData
},

wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tt.WantMock()
ctrl := gomock.NewController(t)
defer ctrl.Finish()

sellerMock := repositories.NewMockISeller(ctrl)
productMock := repositories.NewMockIProduct(ctrl)
orderMock := repositories.NewMockIOrder(ctrl)

s := NewServiceImpl().
WithBuyer(buyerMock).
WithBuyer(tt.WantMock(ctrl)).
WithSeller(sellerMock).
WithOrder(orderMock).
WithProduct(productMock).
WithOrder(orderMock).
WithLog(log).WithConfig(*cfg)

gotToken, err := s.Login(tt.args.ctx, tt.args.payload)
if (err != nil) != tt.wantErr {
t.Errorf("ServiceImpl.Login() error = %v, wantErr %v", err, tt.wantErr)
Expand Down
Loading

0 comments on commit 64f5211

Please sign in to comment.