From c68bbe9e091647922787e072ff022ce3053f1619 Mon Sep 17 00:00:00 2001 From: Dimitrios Liappis Date: Wed, 29 May 2024 11:06:29 +0300 Subject: [PATCH 1/4] Fix bug with NativeArchitecture ending in newline This commit fixes a bug where HostInfo.NativeArchitecture ends in a newline and adds a test. --- providers/linux/arch_linux.go | 2 +- providers/linux/arch_linux_test.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/providers/linux/arch_linux.go b/providers/linux/arch_linux.go index f1d807f..efb3010 100644 --- a/providers/linux/arch_linux.go +++ b/providers/linux/arch_linux.go @@ -81,5 +81,5 @@ func NativeArchitecture() (string, error) { nativeArch := string(data) nativeArch = strings.TrimRight(nativeArch, "\n") - return string(data), nil + return nativeArch, nil } diff --git a/providers/linux/arch_linux_test.go b/providers/linux/arch_linux_test.go index be46203..5d2813f 100644 --- a/providers/linux/arch_linux_test.go +++ b/providers/linux/arch_linux_test.go @@ -18,6 +18,7 @@ package linux import ( + "regexp" "testing" "github.com/stretchr/testify/assert" @@ -27,10 +28,12 @@ func TestArchitecture(t *testing.T) { a, err := Architecture() assert.NoError(t, err) assert.NotEmpty(t, a) + assert.NotRegexp(t, regexp.MustCompile("^.*\n+$"), a, "should not end in newlines") } func TestNativeArchitecture(t *testing.T) { a, err := NativeArchitecture() assert.NoError(t, err) assert.NotEmpty(t, a) + assert.NotRegexp(t, regexp.MustCompile("^.*\n+$"), a, "should not end in newlines") } From 240f0f81ba4a0405310c87b814c5a07e23f48654 Mon Sep 17 00:00:00 2001 From: Dimitrios Liappis Date: Wed, 29 May 2024 11:12:31 +0300 Subject: [PATCH 2/4] Add missing changelog file --- .changelog/223.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/223.txt diff --git a/.changelog/223.txt b/.changelog/223.txt new file mode 100644 index 0000000..e9161f2 --- /dev/null +++ b/.changelog/223.txt @@ -0,0 +1,3 @@ +```release-note:bug +all: Remove newline from HostInfo.NativeArchitecture +``` From 7d260f3f1e4575d62c23a31f48ccb4b8c15baeb6 Mon Sep 17 00:00:00 2001 From: Dimitrios Liappis Date: Wed, 29 May 2024 11:30:57 +0300 Subject: [PATCH 3/4] PR comment --- providers/linux/arch_linux_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/providers/linux/arch_linux_test.go b/providers/linux/arch_linux_test.go index 5d2813f..cae30a6 100644 --- a/providers/linux/arch_linux_test.go +++ b/providers/linux/arch_linux_test.go @@ -24,16 +24,18 @@ import ( "github.com/stretchr/testify/assert" ) +var reNewline = regexp.MustCompile("^.*\n+$") + func TestArchitecture(t *testing.T) { a, err := Architecture() assert.NoError(t, err) assert.NotEmpty(t, a) - assert.NotRegexp(t, regexp.MustCompile("^.*\n+$"), a, "should not end in newlines") + assert.NotRegexp(t, reNewline, a, "should not end in newlines") } func TestNativeArchitecture(t *testing.T) { a, err := NativeArchitecture() assert.NoError(t, err) assert.NotEmpty(t, a) - assert.NotRegexp(t, regexp.MustCompile("^.*\n+$"), a, "should not end in newlines") + assert.NotRegexp(t, reNewline, a, "should not end in newlines") } From 8076c15ad842ea82f1e090f382e18073d3a29a4e Mon Sep 17 00:00:00 2001 From: Dimitrios Liappis Date: Thu, 30 May 2024 00:18:51 +0300 Subject: [PATCH 4/4] Update .changelog/223.txt Co-authored-by: Andrew Kroh --- .changelog/223.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changelog/223.txt b/.changelog/223.txt index e9161f2..c146df4 100644 --- a/.changelog/223.txt +++ b/.changelog/223.txt @@ -1,3 +1,3 @@ ```release-note:bug -all: Remove newline from HostInfo.NativeArchitecture +linux: Remove newline from HostInfo.NativeArchitecture value. ```