From 3ac758b9744b502bce4b547cdf6b374c17f67181 Mon Sep 17 00:00:00 2001 From: przem4l Date: Tue, 30 Jun 2026 17:21:37 +0200 Subject: [PATCH 1/7] docs: update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c2bec0368b7..ab33424780e 100644 --- a/README.md +++ b/README.md @@ -21,3 +21,5 @@ go build -o notely && ./notely *This starts the server in non-database mode.* It will serve a simple webpage at `http://localhost:8080`. You do *not* need to set up a database or any interactivity on the webpage yet. Instructions for that will come later in the course! + +przem4l's version of Boot.dev's Notely app. \ No newline at end of file From 13025e95dd0ef97faa9be404d48c856fa126901b Mon Sep 17 00:00:00 2001 From: przem4l Date: Tue, 30 Jun 2026 17:29:28 +0200 Subject: [PATCH 2/7] feat: add ci.yml --- .github/workflows/ci.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000000..664032071d1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,22 @@ +name: ci + +on: + pull_request: + branches: [main] + +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v6 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: "1.26.0" + + - name: Force Failure + run: (exit 1) \ No newline at end of file From 7280dd3e76c36127b4ca4a612b7f5b6a0eb0bf26 Mon Sep 17 00:00:00 2001 From: przem4l Date: Tue, 30 Jun 2026 17:31:18 +0200 Subject: [PATCH 3/7] feat: update ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 664032071d1..6c056185e2f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,5 +18,5 @@ jobs: with: go-version: "1.26.0" - - name: Force Failure - run: (exit 1) \ No newline at end of file + - name: Get go version + run: go version \ No newline at end of file From 029d5c12915307642f900d863dfca3147f02efb2 Mon Sep 17 00:00:00 2001 From: przem4l Date: Tue, 30 Jun 2026 17:39:51 +0200 Subject: [PATCH 4/7] feat: update broken ci --- .github/workflows/ci.yml | 4 +-- internal/auth/auth.go | 2 +- internal/auth/get_api_key_test.go | 52 +++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 internal/auth/get_api_key_test.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6c056185e2f..41a392de88b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,5 +18,5 @@ jobs: with: go-version: "1.26.0" - - name: Get go version - run: go version \ No newline at end of file + - name: Run get_api_key test + run: go test ./... \ No newline at end of file diff --git a/internal/auth/auth.go b/internal/auth/auth.go index f969aacf638..10ba2dd221b 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -10,7 +10,7 @@ var ErrNoAuthHeaderIncluded = errors.New("no authorization header included") // GetAPIKey - func GetAPIKey(headers http.Header) (string, error) { - authHeader := headers.Get("Authorization") + //authHeader := headers.Get("Authorization") if authHeader == "" { return "", ErrNoAuthHeaderIncluded } diff --git a/internal/auth/get_api_key_test.go b/internal/auth/get_api_key_test.go new file mode 100644 index 00000000000..32093418320 --- /dev/null +++ b/internal/auth/get_api_key_test.go @@ -0,0 +1,52 @@ +package auth + +import ( + "errors" + "net/http" + "testing" +) + +func TestGetAPIKey(t *testing.T) { + t.Parallel() + + tests := []struct { + name string + headers http.Header + want string + wantErr error + }{ + { + name: "returns api key from authorization header", + headers: http.Header{"Authorization": []string{"ApiKey abc123"}}, + want: "abc123", + }, + { + name: "fails when authorization header is missing", + headers: http.Header{}, + wantErr: ErrNoAuthHeaderIncluded, + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + + got, err := GetAPIKey(tt.headers) + if tt.wantErr != nil { + if !errors.Is(err, tt.wantErr) { + t.Fatalf("GetAPIKey() error = %v, want %v", err, tt.wantErr) + } + return + } + + if err != nil { + t.Fatalf("GetAPIKey() unexpected error = %v", err) + } + + if got != tt.want { + t.Fatalf("GetAPIKey() = %q, want %q", got, tt.want) + } + }) + } +} From 418ca17bd40b88e40678a24b1ee37ae14c2938d1 Mon Sep 17 00:00:00 2001 From: przem4l Date: Tue, 30 Jun 2026 17:41:10 +0200 Subject: [PATCH 5/7] feat: fix broken auth.go --- internal/auth/auth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/auth/auth.go b/internal/auth/auth.go index 10ba2dd221b..f969aacf638 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -10,7 +10,7 @@ var ErrNoAuthHeaderIncluded = errors.New("no authorization header included") // GetAPIKey - func GetAPIKey(headers http.Header) (string, error) { - //authHeader := headers.Get("Authorization") + authHeader := headers.Get("Authorization") if authHeader == "" { return "", ErrNoAuthHeaderIncluded } From e48467a56cf4240d0be509f13458f16597a75de5 Mon Sep 17 00:00:00 2001 From: przem4l Date: Tue, 30 Jun 2026 17:50:22 +0200 Subject: [PATCH 6/7] feat: add -cover flag --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 41a392de88b..3437252dfc4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,4 +19,4 @@ jobs: go-version: "1.26.0" - name: Run get_api_key test - run: go test ./... \ No newline at end of file + run: go test -cover ./... \ No newline at end of file From b69ee4d29007bfd096e50040725037bab7a6a245 Mon Sep 17 00:00:00 2001 From: przem4l Date: Tue, 30 Jun 2026 17:56:07 +0200 Subject: [PATCH 7/7] docs: add tests status --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index ab33424780e..a40e750a073 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # learn-cicd-starter (Notely) +Tests status: + +![Tests status](https://github.com/przem4l/bootdev-cicd/actions/workflows/ci.yml/badge.svg) + This repo contains the starter code for the "Notely" application for the "Learn CICD" course on [Boot.dev](https://boot.dev). ## Local Development