Skip to content

Commit

Permalink
Merge branch 'main' into refactor/errors-wrap/replace-errors-wrap-wit…
Browse files Browse the repository at this point in the history
…h-join
  • Loading branch information
kpango authored Apr 18, 2023
2 parents be79683 + af5eba5 commit e2a72fe
Showing 1 changed file with 76 additions and 9 deletions.
85 changes: 76 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ We appreciate your help!

## Table of Contents

- [Contributing Issue](#Contributing-Issue)
- [Bug Report](#Bug-Report)
- [Proposal](#Proposal)
- [Feature Request](#Feature-Request)
- [Security Issue Report](#Security-Issue-Report)
- [Contributing Source Code](#Contributing-Source-Code)
- [Before contributing source code](#Before-contributing-source-code)
- [How to contribute source code](#How-to-contribute-source-code)
- [Branch naming convention](#Branch-naming-convention)
- [Contributing Issue](#contributing-issue)
- [Bug Report](#bug-report)
- [Proposal](#proposal)
- [Feature Request](#feature-request)
- [Security Issue Report](#security-issue-report)
- [Contributing Source Code](#contributing-source-code)
- [Before contributing source code](#before-contributing-source-code)
- [How to contribute source code](#how-to-contribute-source-code)
- [How to contribute unit test code](#how-to-contribute-unit-test-code)
- [Branch naming convention](#branch-naming-convention)

## Contributing Issue

Expand Down Expand Up @@ -111,6 +112,72 @@ Your pull request is much more likely to be accepted if:

- Your pull request is small and focused with a clear message that conveys the intent of your change

### How to contribute unit test code

To contribute unit test code, the steps are almost the same as [contribute source code](#how-to-contribute-source-code), but there are some extra steps when implementing a test function which is not implemented before:

1. Execute `make gotests/gen` command under Vald repository
1. Move the test function which you would like to implement above the placeholder `// NOT IMPLEMENTED BELOW`
1. Implement the test function

Vald implmentes unit test code to ensure the quality of Vald.
Each implementation file comes with its unit test file, with `*_test.go` postfix.
In Vald, unit test files are looks like:

```go
func Test_implementedTest(t *testing.T) {
// this unit test is implemented
}

// NOT IMPLEMENTED BELOW

func Test_notImplementedTest(t *testing.T) {
// this unit test function is not implemented yet
}
```

Vald defines a placeholder `// NOT IMPLEMENTED BELOW` to separate the implemented unit test from the unimplemented unit test.
Everything before the placeholder are already implemented, and everything below are not implemented yet.

If no test functions are implemented in the test file, the placeholder will be placed below the package definition.

```go
package test

// NOT IMPLEMENTED BELOW
func Test_unimplementedTest(t *testing.T) {
// this unit test function is not implemented yet
}

func Test_unimplementedTest2(t *testing.T) {
// this unit test function is not implemented yet
}
```

If all test functions are implemented, the placeholder will be placed on the bottom of the file.

```go
package test

func Test_implementedTest(t *testing.T) {
// this unit test is implemented
}

func Test_implementedTest2(t *testing.T) {
// this unit test is implemented
}

// NOT IMPLEMENTED BELOW
```

<div class="notice">
This implementation structure is generated by the <code class="bash" data-lang="bash">make gotests/gen</code> command for all unit test files by applying the custom unit test template using <a href="https://github.com/cweill/gotests">gotests</a>.
<br>
When the test template is updated, the generated unit test functions will not be updated accordingly, so we need this unit test structure to help us regenerate the implementation with the latest template.
For the implemented unit test, we cannot deal with it by executing <code class="bash" data-lang="bash">make gotests/gen</code> command.
But we don't have to update implemented test soon.
</div>

### Branch naming convention

Name your branches with prefixes: `[type]/[area]/[description]`
Expand Down

0 comments on commit e2a72fe

Please sign in to comment.