Skip to content
This repository was archived by the owner on Nov 7, 2019. It is now read-only.

Commit f671b3b

Browse files
authored
Merge pull request #5 from datatogether/sprint_prep
THAT'S A 🌶 📝
2 parents ddfcecb + 9a2df92 commit f671b3b

File tree

8 files changed

+786
-3
lines changed

8 files changed

+786
-3
lines changed

.circleci/config.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,15 @@ jobs:
3535
command: go-wrapper download && go-wrapper install && go get -v github.com/jstemmer/go-junit-report
3636
- run:
3737
name: Run tests
38-
command: go test -v -race ./... | tee /tmp/test-reports/datatogether/original.txt ; test ${PIPESTATUS[0]} -eq 0
38+
command: go test -v -race -coverprofile=coverage.txt -covermode=atomic | tee /tmp/test-reports/datatogether/original.txt ; test ${PIPESTATUS[0]} -eq 0
3939
- run:
4040
name: Convert test output to junit-style xml
4141
command: cat /tmp/test-reports/datatogether/original.txt | go-junit-report > /tmp/test-reports/datatogether/junit.xml
4242
- store_test_results:
4343
path: /tmp/test-reports/datatogether/junit.xml
44+
- run:
45+
name: Publish coverage info to codecov.io
46+
command: bash <(curl -s https://codecov.io/bash)
4447
- setup_remote_docker
4548
- run:
4649
name: Install Docker client

.github/CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Contributing Guidelines
2+
3+
We love improvements to our tools! Take a moment to check out our organization-wide [Contributing Guidelines](https://github.com/datatogether/datatogether/blob/master/CONTRIBUTING.md) and [Code of Conduct](https://github.com/datatogether/datatogether/blob/master/CONDUCT.md).

.github/ISSUE_TEMPLATE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Hey there, thank you for submitting an issue!
2+
3+
We are trying to keep issues for feature requests and bug reports. Please
4+
complete the following checklist before creating a new one:
5+
6+
- [ ] Is this a **bug report** (if so, is it something you can **debug and fix**?
7+
Send a pull request!)
8+
- [ ] feature request
9+
- [ ] support request => Please do not submit support requests here, ask your question
10+
on [Slack](https://archivers-slack.herokuapp.com/).
11+
12+
---

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.DS_Store
22
gin-bin
3-
sentry
4-
coverage.out
3+
coverage.txt
54
*.env
65
identity

LICENSE

Lines changed: 661 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Identity
2+
3+
[![GitHub](https://img.shields.io/badge/project-Data_Together-487b57.svg?style=flat-square)](http://github.com/datatogether)
4+
[![Slack](https://img.shields.io/badge/slack-Archivers-b44e88.svg?style=flat-square)](https://archivers-slack.herokuapp.com/)
5+
[![License](https://img.shields.io/github/license/mashape/apistatus.svg)](./LICENSE)
6+
[![Codecov](https://img.shields.io/codecov/c/github/datatogether/identity.svg?style=flat-square)](https://codecov.io/gh/datatogether/identity)
7+
8+
[1-3 sentence description of repository contents]
9+
10+
## License & Copyright
11+
12+
[Modelled on [project guidelines template](https://github.com/datatogether/roadmap/blob/master/PROJECT.md#license--copyright-readme-block) ]
13+
14+
## Getting Involved
15+
16+
We would love involvement from more people! If you notice any errors or would like to submit changes, please see our [Contributing Guidelines](./.github/CONTRIBUTING.md).
17+
18+
We use GitHub issues for [tracking bugs and feature requests](https://github.com/datatogether/REPONAME/issues) and Pull Requests (PRs) for [submitting changes](https://github.com/datatogether/REPONAME/pulls)
19+
20+
## ...
21+
22+
## [Optional section(s) on Installation (actually using the service!), Architecture, Dependencies, and Other Considerations]
23+
24+
[fill out this section if the repo contains deployable/installable code]
25+
26+
## Development
27+
28+
[Step-by-step instructions about how to set up a local dev environment and any dependencies]
29+
30+
## Deployment
31+
32+
[Optional section with deployment instructions]

server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ func NewServerRoutes() *http.ServeMux {
9393
m := http.NewServeMux()
9494

9595
m.Handle("/", middleware(NotFoundHandler))
96+
m.Handle("/healthcheck", middleware(HealthCheckHandler))
9697

9798
m.Handle("/publickey", middleware(PublicKeyHandler))
9899

server_test.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package main
2+
3+
import (
4+
"bytes"
5+
"encoding/json"
6+
"net/http"
7+
"net/http/httptest"
8+
"testing"
9+
10+
"github.com/gorilla/sessions"
11+
)
12+
13+
func init() {
14+
cfg = &config{}
15+
sessionStore = sessions.NewCookieStore([]byte(cfg.SessionSecret))
16+
}
17+
18+
func TestServerRoutes(t *testing.T) {
19+
cases := []struct {
20+
method, endpoint string
21+
expectBody bool
22+
body []byte
23+
resStatus int
24+
}{
25+
{"GET", "/", false, nil, 404},
26+
{"GET", "/healthcheck", false, nil, 200},
27+
}
28+
29+
client := &http.Client{}
30+
server := httptest.NewServer(NewServerRoutes())
31+
32+
for i, c := range cases {
33+
req, err := http.NewRequest(c.method, server.URL+c.endpoint, bytes.NewReader(c.body))
34+
if err != nil {
35+
t.Errorf("case %d error creating request: %s", i, err.Error())
36+
continue
37+
}
38+
39+
res, err := client.Do(req)
40+
if err != nil {
41+
t.Errorf("case %d error performing request: %s", i, err.Error())
42+
continue
43+
}
44+
45+
if res.StatusCode != c.resStatus {
46+
t.Errorf("case %d: %s - %s status code mismatch. expected: %d, got: %d", i, c.method, c.endpoint, c.resStatus, res.StatusCode)
47+
continue
48+
}
49+
50+
if c.expectBody {
51+
env := &struct {
52+
Meta map[string]interface{}
53+
Data interface{}
54+
Pagination map[string]interface{}
55+
}{}
56+
57+
if err := json.NewDecoder(res.Body).Decode(env); err != nil {
58+
t.Errorf("case %d: %s - %s error unmarshaling json envelope: %s", i, c.method, c.endpoint, err.Error())
59+
continue
60+
}
61+
62+
if env.Meta == nil {
63+
t.Errorf("case %d: %s - %s doesn't have a meta field", i, c.method, c.endpoint)
64+
continue
65+
}
66+
if env.Data == nil {
67+
t.Errorf("case %d: %s - %s doesn't have a data field", i, c.method, c.endpoint)
68+
continue
69+
}
70+
}
71+
}
72+
}

0 commit comments

Comments
 (0)