Skip to content
Merged
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
5 changes: 3 additions & 2 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ The project is structured as a monorepo to manage the backend, frontend, and sam
- tests/: Common unit tests related files.
- mocks/: Generated mocks for unit tests.
- resources/: Test resource files.
- .mockery.yml: Mockery configurations related to mock generation.
- .mockery.private.yml: Mockery configurations for private interfaces.
- .mockery.public.yml: Mockery configurations for public interfaces.
- frontend/: Individual frontend application code.
- apps/gate/: Gate app implementation which serves UIs for login, registration and recovery.
- packages/: Common frontend packages such as UI components, services, and contexts.
Expand Down Expand Up @@ -113,7 +114,7 @@ The project is structured as a monorepo to manage the backend, frontend, and sam
#### Unit Tests
- Ensure unit tests are written to achieve at least 80% coverage.
- Use `stretchr/testify` for tests and follow the test suite pattern.
- `mockery` is used to generate mocks; configurations are in `/backend/.mockery.yml`.
- `mockery` is used to generate mocks; configurations for private and public interfaces are in `.mockery.private.yml` and `.mockery.public.yml` respectively. Mocks can be generated using `make mockery` command from the project root directory.
- Place generated mocks in the `/backend/tests/mocks/` directory.
- Unit tests can be run using `make test_unit` command from the project root directory. Alternatively `go test` command can also be used from the `/backend` directory with applicable flags.

Expand Down
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ PROJECT_DIR := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))/backen
PROJECT_BIN_DIR := $(PROJECT_DIR)/bin
TOOL_BIN ?= $(PROJECT_BIN_DIR)/tools
GOLANGCI_LINT ?= $(TOOL_BIN)/golangci-lint
MOCKERY ?= $(TOOL_BIN)/mockery

# Tools versions
GOLANGCI_LINT_VERSION ?= v1.64.8
MOCKERY_VERSION ?= v3.5.5

$(TOOL_BIN):
mkdir -p $(TOOL_BIN)
Expand Down Expand Up @@ -95,6 +99,10 @@ docker-build-multiarch-push:
lint: golangci-lint
cd backend && $(GOLANGCI_LINT) run ./...

mockery: install-mockery
cd backend && $(MOCKERY) --config .mockery.public.yml
cd backend && $(MOCKERY) --config .mockery.private.yml

help:
@echo "Makefile targets:"
@echo " all - Clean, build, and test the project."
Expand All @@ -116,13 +124,15 @@ help:
@echo " docker-build-multiarch-latest - Build multi-arch Docker image with latest tag."
@echo " docker-build-multiarch-push - Build and push multi-arch images to registry."
@echo " lint - Run golangci-lint on the project."
@echo " mockery - Generate mocks for unit tests using mockery."
@echo " help - Show this help message."

.PHONY: all prepare clean clean_all build build_samples package_samples run
.PHONY: docker-build docker-build-latest docker-build-multiarch
.PHONY: docker-build-multiarch-latest docker-build-multiarch-push
.PHONY: test_unit test_integration build_with_coverage test
.PHONY: lint help go_install_tool golangci-lint
.PHONY: help go_install_tool
.PHONY: lint golangci-lint mockery install-mockery

define go_install_tool
cd /tmp && \
Expand All @@ -133,3 +143,8 @@ golangci-lint: $(GOLANGCI_LINT)

$(GOLANGCI_LINT): $(TOOL_BIN)
$(call go_install_tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))

install-mockery: $(MOCKERY)

$(MOCKERY): $(TOOL_BIN)
$(call go_install_tool,$(MOCKERY),github.com/vektra/mockery/v3,$(MOCKERY_VERSION))
30 changes: 30 additions & 0 deletions backend/.mockery.private.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# ------------------------------------------------------------------------------
# Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
#
# WSO2 LLC. licenses this file to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file except
# in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ------------------------------------------------------------------------------

# Mockery configuration file for generating private mocks within the package
template: testify
template-data:
unroll-variadic: true
packages:
github.com/asgardeo/thunder/internal/system/cache:
config:
all: true
dir: internal/system/cache
structname: '{{.InterfaceName}}Mock'
pkgname: cache
filename: "{{.InterfaceName}}_mock_test.go"
10 changes: 1 addition & 9 deletions backend/.mockery.yml → backend/.mockery.public.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# under the License.
# ------------------------------------------------------------------------------

# Mockery configuration file for generating public mocks
template: testify
template-data:
unroll-variadic: true
Expand Down Expand Up @@ -59,15 +60,6 @@ packages:
structname: '{{.InterfaceName}}Mock'
pkgname: providermock
filename: "{{.InterfaceName}}_mock.go"

# Uncomment to generate mocks in the cache package.
# github.com/asgardeo/thunder/internal/system/cache:
# config:
# all: true
# dir: internal/system/cache
# structname: '{{.InterfaceName}}Mock'
# pkgname: cache
# filename: "{{.InterfaceName}}_mock_test.go"

github.com/asgardeo/thunder/internal/system/cache:
config:
Expand Down
Loading