Skip to content

Commit 1495d45

Browse files
committed
chore: remove dependency on circle config
Signed-off-by: Peter Schäfer <101886095+PeterSchafer@users.noreply.github.com> chore: update gitignore and add missing file Signed-off-by: Peter Schäfer <101886095+PeterSchafer@users.noreply.github.com> chore: enable docker remote execution Signed-off-by: Peter Schäfer <101886095+PeterSchafer@users.noreply.github.com> chore: switch to machine executor Signed-off-by: Peter Schäfer <101886095+PeterSchafer@users.noreply.github.com> chore: minor updates Signed-off-by: Peter Schäfer <101886095+PeterSchafer@users.noreply.github.com> chore: run examples after a build Signed-off-by: Peter Schäfer <101886095+PeterSchafer@users.noreply.github.com>
1 parent 6be785d commit 1495d45

File tree

3 files changed

+68
-9
lines changed

3 files changed

+68
-9
lines changed

.circleci/config.yml

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
version: 2.1
22

3+
executors:
4+
linux:
5+
machine:
6+
image: ubuntu-2004:2022.07.1
7+
38
# Define the jobs we want to run for this project
49
jobs:
510
unit_test:
6-
docker:
7-
- image: cimg/go:1.18
11+
executor: linux
812
steps:
913
- checkout
1014
- run:
11-
name: run unit tests
15+
name: Run unit tests
1216
command: make test
1317
build:
14-
docker:
15-
- image: cimg/go:1.18
18+
executor: linux
1619
steps:
1720
- checkout
1821
- run:
19-
name: build go app
22+
name: Build
2023
command: make build
21-
24+
- run:
25+
name: Run Examples 1
26+
command: ./example1
27+
2228
# Orchestrate our job run sequence
2329
workflows:
2430
version: 2
@@ -29,5 +35,4 @@ workflows:
2935
- build:
3036
name: Build
3137
requires:
32-
- Lint
3338
- Unit tests

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ statics
66
.history
77
client/node_modules
88
.DS_Store
9+
.dccache
910
lint.xml
1011
cp.out
1112
vendor/
@@ -16,5 +17,4 @@ fmtcoverage.html
1617
coverage.md
1718
coverage.out
1819
kube-knark
19-
mock*
2020
*.iml

test/helper/mock_http_server.go

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package helper
2+
3+
import (
4+
"fmt"
5+
"net"
6+
"net/http"
7+
)
8+
9+
type MockServer struct {
10+
Port int
11+
ResponseList []*http.Response
12+
responseIndex int
13+
listener net.Listener
14+
}
15+
16+
func NewMockServer() *MockServer {
17+
listener, err := net.Listen("tcp", ":0")
18+
if err != nil {
19+
panic(err)
20+
}
21+
22+
server := MockServer{ResponseList: []*http.Response{}}
23+
server.Port = listener.Addr().(*net.TCPAddr).Port
24+
server.listener = listener
25+
fmt.Println("Using port:", listener.Addr().(*net.TCPAddr).Port)
26+
27+
return &server
28+
}
29+
30+
func (m *MockServer) Listen() {
31+
http.Serve(m.listener, m)
32+
}
33+
34+
func (m *MockServer) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
35+
var response *http.Response
36+
37+
if m.responseIndex < len(m.ResponseList) {
38+
response = m.ResponseList[m.responseIndex]
39+
m.responseIndex++
40+
} else {
41+
response = &http.Response{StatusCode: 200}
42+
}
43+
44+
fmt.Printf("%4d. Request: %v\n", m.responseIndex, request)
45+
fmt.Printf("%4d. Response: %v\n", m.responseIndex, response)
46+
47+
for k, v := range response.Header {
48+
for i := range v {
49+
writer.Header().Add(k, v[i])
50+
}
51+
}
52+
53+
writer.WriteHeader(response.StatusCode)
54+
}

0 commit comments

Comments
 (0)