From a758c2a8bb33ae2ce7982a622b072899d95e937d Mon Sep 17 00:00:00 2001 From: Jay Mundrawala Date: Thu, 26 Dec 2024 13:31:17 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20semver=20conversion=20to?= =?UTF-8?q?=20RawData=20(#5012)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- llx/data_conversions.go | 2 +- llx/data_conversions_test.go | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 llx/data_conversions_test.go diff --git a/llx/data_conversions.go b/llx/data_conversions.go index 5fe09c9266..f36948f4e5 100644 --- a/llx/data_conversions.go +++ b/llx/data_conversions.go @@ -59,7 +59,7 @@ func init() { types.Score: pscore2raw, types.Empty: pempty2raw, types.Block: pblock2rawV2, - types.Semver: pscore2raw, + types.Semver: pstring2raw, types.ArrayLike: parray2raw, types.MapLike: pmap2raw, types.ResourceLike: presource2raw, diff --git a/llx/data_conversions_test.go b/llx/data_conversions_test.go new file mode 100644 index 0000000000..79521da9f9 --- /dev/null +++ b/llx/data_conversions_test.go @@ -0,0 +1,20 @@ +// Copyright (c) Mondoo, Inc. +// SPDX-License-Identifier: BUSL-1.1 + +package llx_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v11/llx" + "go.mondoo.com/cnquery/v11/types" +) + +func TestSemver_Conversions(t *testing.T) { + sv := llx.StringPrimitive("1.2.3") + sv.Type = string(types.Semver) + rd := sv.RawData() + require.NoError(t, rd.Error, "no error converting semver to raw data") + require.Equal(t, "1.2.3", rd.Value, "semver to raw data is the same") +}