From 607b8e2fd5b138be712eb74d659cd82f7208c531 Mon Sep 17 00:00:00 2001 From: Saad Afzal Date: Wed, 18 Feb 2026 16:08:42 +0100 Subject: [PATCH 1/8] add a new line to the readme --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c2bec0368b7..cac017e6040 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Run the server: go build -o notely && ./notely ``` -*This starts the server in non-database mode.* It will serve a simple webpage at `http://localhost:8080`. +_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! +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! +Saads's version of Boot.dev's Notely app From 5d016456b606d7c8d5a90f53045826ef70fcb22f Mon Sep 17 00:00:00 2001 From: Saad Afzal Date: Wed, 18 Feb 2026 16:20:41 +0100 Subject: [PATCH 2/8] add CI workflow for testing with Go --- .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..249cc5258a3 --- /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@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.25.1" + + - name: Force Failure + run: (exit 1) From 6161bd09019f3609568e52abf408df0a6e2a3940 Mon Sep 17 00:00:00 2001 From: Saad Afzal Date: Thu, 19 Feb 2026 18:48:53 +0100 Subject: [PATCH 3/8] verify go version in step --- .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 249cc5258a3..1e309f7344e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,5 +18,5 @@ jobs: with: go-version: "1.25.1" - - name: Force Failure - run: (exit 1) + - name: Verify Go version + run: go version From aab0f414031aca3e787277449e3f0f1c84e2285c Mon Sep 17 00:00:00 2001 From: Saad Afzal Date: Fri, 6 Mar 2026 15:15:28 +0100 Subject: [PATCH 4/8] added test run in pipeline and broken code --- .github/workflows/ci.yml | 4 +-- internal/auth/auth.go | 2 +- internal/auth/auth_test.go | 60 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 internal/auth/auth_test.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e309f7344e..be4d53b8b41 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,5 +18,5 @@ jobs: with: go-version: "1.25.1" - - name: Verify Go version - run: go version + - name: Run go tests + run: go test ./.. diff --git a/internal/auth/auth.go b/internal/auth/auth.go index f969aacf638..c23c39ce26b 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("Authorizations") if authHeader == "" { return "", ErrNoAuthHeaderIncluded } diff --git a/internal/auth/auth_test.go b/internal/auth/auth_test.go new file mode 100644 index 00000000000..0621dce1521 --- /dev/null +++ b/internal/auth/auth_test.go @@ -0,0 +1,60 @@ +package auth + +import ( + "net/http" + "testing" +) + +func TestGetAPIKey(t *testing.T) { + tests := []struct { + name string + headers http.Header + wantKey string + wantErr error + wantErrMsg string + }{ + { + name: "valid API key", + headers: http.Header{"Authorization": []string{"ApiKey my-secret-key"}}, + wantKey: "my-secret-key", + wantErr: nil, + }, + { + name: "no authorization header", + headers: http.Header{}, + wantKey: "", + wantErr: ErrNoAuthHeaderIncluded, + }, + { + name: "malformed header - wrong prefix", + headers: http.Header{"Authorization": []string{"Bearer my-token"}}, + wantKey: "", + wantErrMsg: "malformed authorization header", + }, + { + name: "malformed header - no space", + headers: http.Header{"Authorization": []string{"ApiKey"}}, + wantKey: "", + wantErrMsg: "malformed authorization header", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + gotKey, gotErr := GetAPIKey(tt.headers) + if gotKey != tt.wantKey { + t.Errorf("GetAPIKey() key = %q, want %q", gotKey, tt.wantKey) + } + if tt.wantErr != nil { + if gotErr != tt.wantErr { + t.Errorf("GetAPIKey() error = %v, want %v", gotErr, tt.wantErr) + } + } else if tt.wantErrMsg != "" { + if gotErr == nil || gotErr.Error() != tt.wantErrMsg { + t.Errorf("GetAPIKey() error = %v, want error with message %q", gotErr, tt.wantErrMsg) + } + } else if gotErr != nil { + t.Errorf("GetAPIKey() unexpected error = %v", gotErr) + } + }) + } +} From 2274f07d20164bf82edeb953e34912e40c310870 Mon Sep 17 00:00:00 2001 From: Saad Afzal Date: Fri, 6 Mar 2026 15:19:38 +0100 Subject: [PATCH 5/8] fix CI workflow: correct Go version and test command --- .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 be4d53b8b41..db48667cb9c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: "1.25.1" + go-version: "1.23" - name: Run go tests - run: go test ./.. + run: go test ./... From 9a81397a309514efab5f5e359f77b498efccae76 Mon Sep 17 00:00:00 2001 From: Saad Afzal Date: Fri, 6 Mar 2026 15:31:35 +0100 Subject: [PATCH 6/8] fixed type --- 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 c23c39ce26b..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("Authorizations") + authHeader := headers.Get("Authorization") if authHeader == "" { return "", ErrNoAuthHeaderIncluded } From cf74bf2a1d55ae1583a02caca84885787354abca Mon Sep 17 00:00:00 2001 From: Saad Afzal Date: Fri, 6 Mar 2026 16:15:57 +0100 Subject: [PATCH 7/8] add -cover flag to go test command in CI Co-Authored-By: Claude Opus 4.5 --- .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 db48667cb9c..36bff04a744 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,4 +19,4 @@ jobs: go-version: "1.23" - name: Run go tests - run: go test ./... + run: go test -cover ./... From 4e56f87239991c0aa29db0971f4b9f9362c9181b Mon Sep 17 00:00:00 2001 From: Saad Afzal Date: Fri, 6 Mar 2026 16:23:29 +0100 Subject: [PATCH 8/8] fix CI badge URL and alt text in README Co-Authored-By: Claude Opus 4.5 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index cac017e6040..1ca1f3cb746 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +![CI](https://github.com/sadodk/learn-cicd-starter/actions/workflows/ci.yml/badge.svg) + # learn-cicd-starter (Notely) This repo contains the starter code for the "Notely" application for the "Learn CICD" course on [Boot.dev](https://boot.dev).