From 6630fafcc429e438373bcd412e26b84cf518f4f4 Mon Sep 17 00:00:00 2001 From: thgzr Date: Tue, 23 Sep 2025 06:34:59 +0000 Subject: [PATCH 1/6] updated README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c2bec0368b..984004f65c 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! + + Igor's version of Boot.dev's Notely app. From cd63793ae9750d448ea20d968407340642f2b9ac Mon Sep 17 00:00:00 2001 From: thgzr Date: Tue, 23 Sep 2025 06:45:23 +0000 Subject: [PATCH 2/6] added workflows --- .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 0000000000..249cc5258a --- /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 8117cbf4fb683560529699981393385504202110 Mon Sep 17 00:00:00 2001 From: thgzr Date: Tue, 23 Sep 2025 06:51:21 +0000 Subject: [PATCH 3/6] further update of workflows --- .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 249cc5258a..4b5fd86b88 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: Check go version + run: go version \ No newline at end of file From f8a4e41af9d4b9aee05ff565666059dac6165f88 Mon Sep 17 00:00:00 2001 From: thgzr Date: Tue, 23 Sep 2025 07:45:36 +0000 Subject: [PATCH 4/6] added auth tests --- .github/workflows/ci.yml | 4 ++-- internal/auth/auth_test.go | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 internal/auth/auth_test.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b5fd86b88..9e5d0f7baa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,5 +18,5 @@ jobs: with: go-version: "1.25.1" - - name: Check go version - run: go version \ No newline at end of file + - name: Run some tests + run: go test ./... \ No newline at end of file diff --git a/internal/auth/auth_test.go b/internal/auth/auth_test.go new file mode 100644 index 0000000000..63a9236245 --- /dev/null +++ b/internal/auth/auth_test.go @@ -0,0 +1,35 @@ +package auth + +import ( + "net/http" + "reflect" + "testing" +) + +// GetAPIKey - +func TestGetAPIKey(t *testing.T) { + req, _ := http.NewRequest("GET", "/", nil) + req.Header.Set("Authorization", "ApiKey sometoken") + got, err := GetAPIKey(req.Header) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + want := "sometoken" + if !reflect.DeepEqual(want, got) { + t.Fatalf("expected: %v, got: %v", want, got) + } + + req, _ = http.NewRequest("GET", "/", nil) + // req.Header.Del("Authorization") + + got, err = GetAPIKey(req.Header) + if err == nil { + t.Fatalf("expected error, got nil") + } + if got != "" { + t.Fatalf("expected empty token, got %q", got) + } + if err.Error() != "no authorization header included" { + t.Fatalf("unexpected error: %v", err) + } +} From 96b76494a1f79e1631c373d29e1a3c098f7d07ea Mon Sep 17 00:00:00 2001 From: thgzr Date: Tue, 23 Sep 2025 07:48:29 +0000 Subject: [PATCH 5/6] added tests 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 9e5d0f7baa..6d716e315b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,4 +19,4 @@ jobs: go-version: "1.25.1" - name: Run some tests - run: go test ./... \ No newline at end of file + run: go test ./... -cover \ No newline at end of file From 72339b72c56386b1f97873e9548bd23e15f9e4db Mon Sep 17 00:00:00 2001 From: thgzr Date: Tue, 23 Sep 2025 08:37:48 +0000 Subject: [PATCH 6/6] added badge to README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 984004f65c..0fe0bf68de 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +![CI](https://github.com/thgzr/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).