From dda5ae71610b72c81bd54f5749bd254d804b7abc Mon Sep 17 00:00:00 2001 From: Ivo Forlin Date: Mon, 15 Sep 2025 19:02:16 +0200 Subject: [PATCH 1/7] ci: created build-and-test pipeline --- .github/workflows/build-and-test.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/build-and-test.yml diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..bf8a1d1 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,28 @@ +# This workflow will build a golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: Go + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.25' + + - name: Build + run: go build -v ./... + + - name: Test + run: go test -v ./... From 260d0080d3c792bc9a40cb26b3b21fec65cb0b09 Mon Sep 17 00:00:00 2001 From: Ivo Forlin Date: Mon, 24 Nov 2025 13:01:31 +0100 Subject: [PATCH 2/7] tests: local aware test for running on pipeline --- .github/workflows/build-and-test.yml | 1 - processor_test.go | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index bf8a1d1..33b5845 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -10,7 +10,6 @@ on: branches: [ "main" ] jobs: - build: runs-on: ubuntu-latest steps: diff --git a/processor_test.go b/processor_test.go index 6afa3bc..2058859 100644 --- a/processor_test.go +++ b/processor_test.go @@ -95,9 +95,9 @@ func TestProcessEndDateError(t *testing.T) { func TestParseIsoLocal(t *testing.T) { parsedDate, err := parseIsoLocal("20230101T003000Z") if err != nil { - t.Errorf("Error while parsing date") + t.Errorf("Error while parsing date %v", err) } - expectedDate := time.Date(2023, 01, 01, 01, 30, 0, 0, time.Local) + expectedDate := time.Date(2023, 01, 01, 01, 30, 0, 0, time.Local).Local() if parsedDate != expectedDate { t.Errorf("Expected start date to be [%v], found instead [%v]", expectedDate, parsedDate) } From 391fd24418531a2589a9a91fba46f746ff292cb7 Mon Sep 17 00:00:00 2001 From: Ivo Forlin Date: Mon, 24 Nov 2025 13:01:31 +0100 Subject: [PATCH 3/7] tests: local aware test for running on pipeline --- processor_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/processor_test.go b/processor_test.go index 2058859..668834e 100644 --- a/processor_test.go +++ b/processor_test.go @@ -97,7 +97,7 @@ func TestParseIsoLocal(t *testing.T) { if err != nil { t.Errorf("Error while parsing date %v", err) } - expectedDate := time.Date(2023, 01, 01, 01, 30, 0, 0, time.Local).Local() + expectedDate := time.Date(2023, 01, 01, 00, 30, 0, 0, time.UTC).Local() if parsedDate != expectedDate { t.Errorf("Expected start date to be [%v], found instead [%v]", expectedDate, parsedDate) } From 6639d35d3214cf253bab6fa3afc75f321063539d Mon Sep 17 00:00:00 2001 From: Ivo Forlin Date: Mon, 24 Nov 2025 13:01:31 +0100 Subject: [PATCH 4/7] tests: local aware test for running on pipeline --- output_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/output_test.go b/output_test.go index c92e1f3..167779b 100644 --- a/output_test.go +++ b/output_test.go @@ -1,14 +1,18 @@ package timewlib import ( + "fmt" "testing" + "time" ) func TestGenerateNoDataMessageComplete(t *testing.T) { var config Configuration = map[string]string{"temp.report.start": "20240308T230000Z", "temp.report.end": "20240309T230000Z"} message := GenerateNoDataMessage(config) t.Log(message) - expected := "No filtered data found in the range 2024-03-09T00:00:00 - 2024-03-10T00:00:00." + startDate := time.Date(2024, 3, 8, 23, 0, 0, 0, time.UTC).Local().Format("2006-01-02T15:04:05") + endDate := time.Date(2024, 3, 9, 23, 0, 0, 0, time.UTC).Local().Format("2006-01-02T15:04:05") + expected := fmt.Sprintf("No filtered data found in the range %s - %s.", startDate, endDate) if message != expected { t.Fatalf("Actual message [%s] is different from expected [%s]", message, expected) } From 633438501b0a909a0ca5f2b5fa7579765c1ef2bf Mon Sep 17 00:00:00 2001 From: Ivo Forlin Date: Mon, 24 Nov 2025 13:01:31 +0100 Subject: [PATCH 5/7] tests: local aware test for running on pipeline --- interval_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interval_test.go b/interval_test.go index b94f224..ad705a3 100644 --- a/interval_test.go +++ b/interval_test.go @@ -31,7 +31,7 @@ func TestNewInterval(t *testing.T) { t.Errorf("interval.IsSameHour() is not correct :%t", interval.IsSameHour()) } today := time.Now().Format("2006-01-02") - timezone := time.Now().Format("Z0700 MST") + timezone := time.Now().Local().Format("Z0700 MST") expectedStringValue := fmt.Sprintf("[%s 10:00:00 %s-%s 10:30:00 %s]", today, timezone, today, timezone) if interval.String() != expectedStringValue { t.Errorf("interval.String() is not correct :%s != %s", expectedStringValue, interval.String()) From 0e8764c1b402097607a8efb4de486e4c598edd97 Mon Sep 17 00:00:00 2001 From: Ivo Forlin Date: Mon, 24 Nov 2025 13:01:31 +0100 Subject: [PATCH 6/7] tests: local aware test for running on pipeline --- configuration_test.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/configuration_test.go b/configuration_test.go index 5a87ce3..a608a03 100644 --- a/configuration_test.go +++ b/configuration_test.go @@ -3,6 +3,7 @@ package timewlib import ( "fmt" "testing" + "time" ) var testCases = map[string]bool{ @@ -54,22 +55,24 @@ func TestRequireConfirmation(t *testing.T) { func TestGetReportStartDate(t *testing.T) { var config Configuration = map[string]string{"temp.report.start": "20240308T230000Z"} start, err := config.GetReportStartDate() + var expected = time.Date(2024, 3, 8, 23, 0, 0, 0, time.UTC).Local() if err != nil { t.Fatal(err) } - if start.Day() != 9 || start.Month() != 3 || start.Year() != 2024 || start.Hour() != 0 || start.Minute() != 0 { - t.Fatalf("Parsed date is not 20240308T230000Z but %s", start) + if expected != start { + t.Fatalf("Parsed date is not %s but %s", expected, start) } } func TestGetReportEndDate(t *testing.T) { var config Configuration = map[string]string{"temp.report.end": "20240309T230000Z"} - start, err := config.GetReportEndDate() + end, err := config.GetReportEndDate() + var expected = time.Date(2024, 3, 9, 23, 0, 0, 0, time.UTC).Local() if err != nil { t.Fatal(err) } - if start.Day() != 10 || start.Month() != 3 || start.Year() != 2024 || start.Hour() != 0 || start.Minute() != 0 { - t.Fatalf("Parsed date is not 20240309T230000Z but %s", start) + if expected != end { + t.Fatalf("Parsed date is not %s but %s", expected, end) } } From a1c57eb3fd4b6d6f8ef21edaf5293d01ba7a0034 Mon Sep 17 00:00:00 2001 From: Ivo Forlin Date: Mon, 24 Nov 2025 13:01:31 +0100 Subject: [PATCH 7/7] tests: local aware test for running on pipeline --- interval_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interval_test.go b/interval_test.go index ad705a3..5016556 100644 --- a/interval_test.go +++ b/interval_test.go @@ -31,7 +31,7 @@ func TestNewInterval(t *testing.T) { t.Errorf("interval.IsSameHour() is not correct :%t", interval.IsSameHour()) } today := time.Now().Format("2006-01-02") - timezone := time.Now().Local().Format("Z0700 MST") + timezone := time.Now().Local().Format("-0700 MST") expectedStringValue := fmt.Sprintf("[%s 10:00:00 %s-%s 10:30:00 %s]", today, timezone, today, timezone) if interval.String() != expectedStringValue { t.Errorf("interval.String() is not correct :%s != %s", expectedStringValue, interval.String())