From 17e9000db44181e0fb6f519a43b84a889ce3d889 Mon Sep 17 00:00:00 2001 From: Graham Gilbert Date: Thu, 11 Jul 2024 16:13:53 -0700 Subject: [PATCH] move --- BUILD.bazel | 9 +-------- main.go | 6 +----- main_test.go | 12 ------------ tables/sofa/client.go | 4 ++++ tables/sofa/client_test.go | 8 ++++++++ 5 files changed, 14 insertions(+), 25 deletions(-) delete mode 100644 main_test.go diff --git a/BUILD.bazel b/BUILD.bazel index 568ca74..1561664 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") load("@bazel_gazelle//:def.bzl", "gazelle") # load(":rules.bzl", "foo_binary") @@ -103,10 +103,3 @@ go_binary( goos = "linux", visibility = ["//visibility:public"], ) - -go_test( - name = "osquery-extension_test", - srcs = ["main_test.go"], - embed = [":osquery-extension_lib"], - deps = ["@com_github_stretchr_testify//assert"], -) diff --git a/main.go b/main.go index d51284b..3502282 100644 --- a/main.go +++ b/main.go @@ -44,7 +44,7 @@ func main() { panic("Version not set") } - useragent := buildUserAgent(Version) + useragent := sofa.BuildUserAgent(Version) sofaOpts := []sofa.Option{ sofa.WithUserAgent(useragent), } @@ -113,7 +113,3 @@ func main() { log.Fatalln(err) } } - -func buildUserAgent(version string) string { - return "macadmins-osquery-extension/" + version -} diff --git a/main_test.go b/main_test.go deleted file mode 100644 index fc74855..0000000 --- a/main_test.go +++ /dev/null @@ -1,12 +0,0 @@ -package main - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestVersionIsValid(t *testing.T) { - assert.NotEmpty(t, Version) - assert.NotEqual(t, "0", Version) -} diff --git a/tables/sofa/client.go b/tables/sofa/client.go index 9d3c19c..353b033 100644 --- a/tables/sofa/client.go +++ b/tables/sofa/client.go @@ -296,3 +296,7 @@ func (s *SofaClient) downloadSofaJSON() (Root, error) { return s.loadCachedData() } + +func BuildUserAgent(version string) string { + return "macadmins-osquery-extension/" + version +} diff --git a/tables/sofa/client_test.go b/tables/sofa/client_test.go index 858a88b..6dca003 100644 --- a/tables/sofa/client_test.go +++ b/tables/sofa/client_test.go @@ -369,3 +369,11 @@ func TestCreateCacheDir(t *testing.T) { assert.DirExists(t, client.cacheDir) } + +func TestBuildUserAgent(t *testing.T) { + version := "1.0.0" + expectedUserAgent := "macadmins-osquery-extension/1.0.0" + userAgent := BuildUserAgent(version) + + assert.Equal(t, expectedUserAgent, userAgent) +}