Skip to content

Commit 92d4610

Browse files
rename variables for clarity
1 parent a7e8da7 commit 92d4610

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

internal/commands/sendtestdata/postdata.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ func PostTestData(data any, URL string, headers map[string]string) (string, erro
4040
return bodyString, nil
4141
}
4242

43-
func PostTestDataToObserve(data any, path string, v *viper.Viper) (string, error) {
43+
func PostDataToObserve(data any, extraPath string, v *viper.Viper) (string, error) {
4444
collector_url := v.GetString("observe_url")
45-
endpoint := fmt.Sprintf("%s/v1/http%s", strings.TrimRight(collector_url, "/"), path)
45+
endpoint := fmt.Sprintf("%s/v1/http%s", strings.TrimRight(collector_url, "/"), extraPath)
4646
authToken := fmt.Sprintf("Bearer %s", v.GetString("token"))
4747
return PostTestData(data, endpoint, map[string]string{"Authorization": authToken})
4848
}

internal/commands/sendtestdata/postdata_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func TestPostTestData(t *testing.T) {
3030
assert.Equal(t, expectedResponse, resp)
3131
}
3232

33-
func TestPostTestDataToObserve(t *testing.T) {
33+
func TestPostDataToObserve(t *testing.T) {
3434
httpmock.Activate()
3535
t.Cleanup(httpmock.DeactivateAndReset)
3636

@@ -48,7 +48,7 @@ func TestPostTestDataToObserve(t *testing.T) {
4848
v.Set("observe_url", "https://123456.collect.observe-eng.com/")
4949
v.Set("token", "test-token")
5050
testData := map[string]string{"hello": "world"}
51-
resp, err := PostTestDataToObserve(testData, "/test", v)
51+
resp, err := PostDataToObserve(testData, "/test", v)
5252
assert.NoError(t, err)
5353
assert.Equal(t, expectedResponse, resp)
5454
}

internal/commands/sendtestdata/sendtestdata.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/spf13/viper"
1313
)
1414

15-
const TestDataPath = "/observe-agent/test"
15+
const TestDataExtraPath = "/observe-agent/test"
1616

1717
var defaultTestData = map[string]any{
1818
"hello": "world",
@@ -34,7 +34,7 @@ func NewSendTestDataCmd() *cobra.Command {
3434
} else {
3535
testData = defaultTestData
3636
}
37-
respBody, err := PostTestDataToObserve(testData, TestDataPath, viper.GetViper())
37+
respBody, err := PostDataToObserve(testData, TestDataExtraPath, viper.GetViper())
3838
if err != nil {
3939
return err
4040
}

0 commit comments

Comments
 (0)