This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from neicnordic/test/unit-tests
WIP Test/unit tests
- Loading branch information
Showing
22 changed files
with
2,404 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Tests | ||
|
||
on: [push] | ||
|
||
jobs: | ||
|
||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
go-version: [1.16] | ||
steps: | ||
|
||
- name: Set up Go ${{ matrix.go-version }} | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
id: go | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get dependencies | ||
run: | | ||
go get -v -t -d ./... | ||
if [ -f Gopkg.toml ]; then | ||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh | ||
dep ensure | ||
fi | ||
- name: Test | ||
run: go test -v -coverprofile=coverage.txt -covermode=atomic ./... | ||
|
||
- name: Codecov | ||
uses: codecov/[email protected] | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
file: ./coverage.txt | ||
flags: unittests | ||
fail_ci_if_error: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Known Issues and Troubleshooting | ||
|
||
## Files metadata endpoint doesn't work with visas | ||
If using GA4GH Visas with `/metadata/datasets/{dataset}/files`, e.g. `/metadata/datasets/https://doi.org/abc/123/files`, a reverse proxy might remove adjacent slashes `//`->`/`. | ||
This has been observed with nginx, with a fix as follows: | ||
|
||
[disable slash merging](http://nginx.org/en/docs/http/ngx_http_core_module.html#merge_slashes) | ||
in `server` context | ||
``` | ||
server { | ||
merge_slashes off | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package api | ||
|
||
import ( | ||
"crypto/tls" | ||
"testing" | ||
|
||
"github.com/neicnordic/sda-download/internal/config" | ||
) | ||
|
||
func TestSetup(t *testing.T) { | ||
|
||
// Create web server app | ||
config.Config.App.Host = "localhost" | ||
config.Config.App.Port = 8080 | ||
server := Setup() | ||
|
||
// Verify that TLS is configured and set for minimum suggested version | ||
if server.TLSConfig.MinVersion < tls.VersionTLS12 { | ||
t.Errorf("server TLS version is too low, expected=%d, got=%d", tls.VersionTLS12, server.TLSConfig.MinVersion) | ||
} | ||
|
||
// Verify that server address is correctly read from config | ||
expectedAddress := "localhost:8080" | ||
if server.Addr != expectedAddress { | ||
t.Errorf("server address was not correctly formed, expected=%s, received=%s", expectedAddress, server.Addr) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.