From deabc3b7593265de4b5b5f3eb5d480f3ba42ec44 Mon Sep 17 00:00:00 2001 From: bishshshrestha Date: Mon, 15 Dec 2025 02:09:16 +0000 Subject: [PATCH 1/5] Add personalized README line --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c2bec0368b7..f88c8f89f09 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! + +Bisheshshrestha's version of Boot.dev's Notely app. From 2c3b824143ace5ad0cb83d1c0028ef6c191ed6ac Mon Sep 17 00:00:00 2001 From: bishshshrestha Date: Mon, 15 Dec 2025 15:47:13 +0000 Subject: [PATCH 2/5] Continuous Integration --- .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 f6c7dc40f20aabcaffb0283654bbcbca58f769e8 Mon Sep 17 00:00:00 2001 From: bishshshrestha Date: Mon, 15 Dec 2025 16:15:39 +0000 Subject: [PATCH 3/5] test: verify CI catches failures --- .github/workflows/ci.yml | 4 +- internal/auth/fet_api_key_test.go | 62 +++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 internal/auth/fet_api_key_test.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 249cc5258a3..763af7b1f6b 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: Run unit tests + run: go test ./... diff --git a/internal/auth/fet_api_key_test.go b/internal/auth/fet_api_key_test.go new file mode 100644 index 00000000000..5ac1cd99d36 --- /dev/null +++ b/internal/auth/fet_api_key_test.go @@ -0,0 +1,62 @@ +package auth + +import ( + "fmt" + "net/http" + "strings" + "testing" +) + +func TestGetAPIKey(t *testing.T) { + tests := []struct { + key string + value string + expect string + expectErr string + }{ + { + expectErr: "no authorization header", + }, + { + key: "Authorization", + expectErr: "no authorization header", + }, + { + key: "Authorization", + value: "-", + expectErr: "malformed authorization header", + }, + { + key: "Authorization", + value: "Bearer xxxxxx", + expectErr: "malformed authorization header", + }, + { + key: "Authorization", + value: "ApiKey xxxxxx", + expect: "xxxxxx", + expectErr: "not expecting an error", + }, + } + + for i, test := range tests { + t.Run(fmt.Sprintf("TestGetAPIKey Case #%v:", i), func(t *testing.T) { + header := http.Header{} + header.Add(test.key, test.value) + + output, err := GetAPIKey(header) + if err != nil { + if strings.Contains(err.Error(), test.expectErr) { + return + } + t.Errorf("Unexpected: TestGetAPIKey:%v\n", err) + return + } + + if output != test.expect { + t.Errorf("Unexpected: TestGetAPIKey:%s", output) + return + } + }) + } +} From e45c976e58a845aea47da111338c498698dd39a5 Mon Sep 17 00:00:00 2001 From: bishshshrestha Date: Mon, 15 Dec 2025 16:20:49 +0000 Subject: [PATCH 4/5] test: verify CI catches failures with -cover --- .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 763af7b1f6b..91aadb922d8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,4 +19,4 @@ jobs: go-version: "1.25.1" - name: Run unit tests - run: go test ./... + run: go test -cover ./... From b0fc6f4c36843c10959402bfc369207d67ff6359 Mon Sep 17 00:00:00 2001 From: bishshshrestha Date: Mon, 15 Dec 2025 16:26:13 +0000 Subject: [PATCH 5/5] README badge for tests --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f88c8f89f09..e782313bfb9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # learn-cicd-starter (Notely) +![CI](https://github.com/bisheshshrestha/learn-cicd-starter/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