Skip to content

Commit

Permalink
rm temp file from t.cleanup and use fmt.Sprintf insted of constants
Browse files Browse the repository at this point in the history
Signed-off-by: Harshvir Potpose <hpotpose62@gmail.com>
  • Loading branch information
akagami-harsh committed Apr 22, 2024
1 parent ee84793 commit f35a6a4
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions cmd/jaeger/internal/integration/badger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package integration

import (
"fmt"
"net/http"
"os"
"os/exec"
Expand All @@ -17,11 +18,6 @@ import (
"github.com/jaegertracing/jaeger/plugin/storage/integration"
)

const (
host = "0.0.0.0"
Addr = "http://" + host + ":" + storagecleaner.Port + storagecleaner.URL
)

type BadgerStorageIntegration struct {
E2EStorageIntegration
logger *zap.Logger
Expand All @@ -35,6 +31,7 @@ func (s *BadgerStorageIntegration) initialize(t *testing.T) {
}

func (s *BadgerStorageIntegration) cleanUp(t *testing.T) {
Addr := fmt.Sprintf("http://%s:%s%s", "0.0.0.0", storagecleaner.Port, storagecleaner.URL)
r, err := http.NewRequest(http.MethodPost, Addr, nil)
require.NoError(t, err)

Expand Down Expand Up @@ -63,7 +60,6 @@ func TestBadgerStorage(t *testing.T) {
},
},
}
defer s.rmBadgerCleanerConfig(t)
s.initialize(t)
t.Cleanup(func() {
s.e2eCleanUp(t)
Expand All @@ -77,10 +73,8 @@ func createBadgerCleanerConfig(t *testing.T) string {
require.NoError(t, err)
tempFile := string(data)
tempFile = strings.ReplaceAll(tempFile, "\n", "")
t.Cleanup(func() {
os.Remove(tempFile)
})
return tempFile
}

func (s *BadgerStorageIntegration) rmBadgerCleanerConfig(t *testing.T) {
err := os.Remove(s.ConfigFile)
require.NoError(t, err)
}

0 comments on commit f35a6a4

Please sign in to comment.