From 9fbbe4a80f7dc42f955ff87f855751d40a63563d Mon Sep 17 00:00:00 2001 From: PBearATX Date: Sat, 8 Nov 2025 14:54:48 -0800 Subject: [PATCH 1/9] adding line to README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c2bec0368b7..315bc07c7cf 100644 --- a/README.md +++ b/README.md @@ -20,4 +20,6 @@ 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! +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 + +Patrick's version of Boot.dev's Notely app. From e69888c6771f39ea2051331b19ef35d3d45bcfaf Mon Sep 17 00:00:00 2001 From: PBearATX Date: Sat, 8 Nov 2025 15:05:30 -0800 Subject: [PATCH 2/9] Adding initial force failure test --- .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..a54d8248d54 --- /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) \ No newline at end of file From 3b614bd44314d2e4e9aebcc6204c04e491d36441 Mon Sep 17 00:00:00 2001 From: PBearATX Date: Sat, 8 Nov 2025 15:11:21 -0800 Subject: [PATCH 3/9] Replacing with go version --- .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 a54d8248d54..f3729b0e312 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) \ No newline at end of file + - name: Go Verion + run: go version \ No newline at end of file From 7ccc0a47f28116a6a99342fe5af0666361b67f7c Mon Sep 17 00:00:00 2001 From: PBearATX Date: Sat, 8 Nov 2025 15:33:00 -0800 Subject: [PATCH 4/9] Adding auth_test --- internal/auth/auth_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 internal/auth/auth_test.go diff --git a/internal/auth/auth_test.go b/internal/auth/auth_test.go new file mode 100644 index 00000000000..d3fedfee59b --- /dev/null +++ b/internal/auth/auth_test.go @@ -0,0 +1,34 @@ +package auth + +import ( + "net/http" + "reflect" + "testing" +) + +func TestGetAPIKey(t *testing.T) { + header := http.Header{ + "Authorization": []string{"ApiKey my-secret-key"}, + } + got, _ := GetAPIKey(header) + want := "my-secret-key" + if !reflect.DeepEqual(want, got){ + t.Fatalf("expected: %v, got: %v", want, got) + } +} +func TestGetAPIKey_NoHeader(t *testing.T) { + header := http.Header{} + _, err := GetAPIKey(header) + if err != ErrNoAuthHeaderIncluded { + t.Fatalf("expected: %v, got: %v", ErrNoAuthHeaderIncluded, err) + } +} +func TestGetAPIKey_MalformedHeader(t *testing.T) { + header := http.Header{ + "Authorization": []string{"Bearer my-secret-key"}, + } + _, err := GetAPIKey(header) + if err == nil || err.Error() != "malformed authorization header" { + t.Fatalf("expected: %v, got: %v", "malformed authorization header", err) + } +} \ No newline at end of file From 6b2c45f2b0c5b9992d2d2bbc0b3e0c5e3fd13312 Mon Sep 17 00:00:00 2001 From: PBearATX Date: Sat, 8 Nov 2025 15:36:00 -0800 Subject: [PATCH 5/9] breaking the code --- .github/workflows/ci.yml | 4 ++-- internal/auth/auth.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f3729b0e312..8582361cc8c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,5 +18,5 @@ jobs: with: go-version: "1.25.1" - - name: Go Verion - run: go version \ No newline at end of file + - name: Run Go tests + run: go test ./... \ No newline at end of file diff --git a/internal/auth/auth.go b/internal/auth/auth.go index f969aacf638..a449e5c0765 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -15,7 +15,7 @@ func GetAPIKey(headers http.Header) (string, error) { return "", ErrNoAuthHeaderIncluded } splitAuth := strings.Split(authHeader, " ") - if len(splitAuth) < 2 || splitAuth[0] != "ApiKey" { + if len(splitAuth) < 2 || splitAuth[0] != "Apiley" { return "", errors.New("malformed authorization header") } From 348c0f6e0e643dc43d66168d4ddcdec4a8af0a11 Mon Sep 17 00:00:00 2001 From: PBearATX Date: Sat, 8 Nov 2025 15:37:14 -0800 Subject: [PATCH 6/9] fixing the code --- 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 a449e5c0765..f969aacf638 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -15,7 +15,7 @@ func GetAPIKey(headers http.Header) (string, error) { return "", ErrNoAuthHeaderIncluded } splitAuth := strings.Split(authHeader, " ") - if len(splitAuth) < 2 || splitAuth[0] != "Apiley" { + if len(splitAuth) < 2 || splitAuth[0] != "ApiKey" { return "", errors.New("malformed authorization header") } From 384bd7461070ee215261bc4342697b74dea2463c Mon Sep 17 00:00:00 2001 From: PBearATX Date: Sat, 8 Nov 2025 15:40:55 -0800 Subject: [PATCH 7/9] printing code coverage --- .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 8582361cc8c..b224859364e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,4 +19,4 @@ jobs: go-version: "1.25.1" - name: Run Go tests - run: go test ./... \ No newline at end of file + run: go test ./... -cover \ No newline at end of file From cf117a70a1cae0626b5d59abdce97bf09117b1e2 Mon Sep 17 00:00:00 2001 From: PBearATX Date: Sat, 8 Nov 2025 15:47:44 -0800 Subject: [PATCH 8/9] maybe adding a test badge at the top of readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 315bc07c7cf..6d1d3996425 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +![Test Info](https://github.com///actions/workflows//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). From 1d16a428ccab2891e675b82ec380fe2dbdc6de0c Mon Sep 17 00:00:00 2001 From: PBearATX Date: Sat, 8 Nov 2025 15:50:25 -0800 Subject: [PATCH 9/9] explicit url --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6d1d3996425..c7a2b9616dc 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![Test Info](https://github.com///actions/workflows//badge.svg) +![Test Info](https://github.com/pbearatx/learn-cicd-starter/actions/workflows/ci.yml/badge.svg) # learn-cicd-starter (Notely)