Skip to content

Commit

Permalink
Merge pull request #27 from Photoroom/ben/nit_ci_race_detection
Browse files Browse the repository at this point in the history
  • Loading branch information
blefaudeux authored Nov 7, 2024
2 parents 299a8c4 + f7e1c53 commit 99d5af7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ jobs:
DATAROOM_TEST_SOURCE: ${{ secrets.DATAROOM_TEST_SOURCE }}
DATAROOM_API_URL: ${{ secrets.DATAROOM_API_URL }}

run: cd tests && go test -v .
run: cd tests && go test -race -v .
11 changes: 4 additions & 7 deletions pkg/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ type DatagoClient struct {

// GetClient is a constructor for the DatagoClient, given a JSON configuration string
func GetClient(config DatagoConfig) *DatagoClient {
// Initialize the vips library
vips.LoggingSettings(nil, vips.LogLevelWarning)
vips.Startup(nil)

// Create the generator and backend
var generator Generator
var backend Backend
Expand Down Expand Up @@ -202,13 +206,6 @@ func (c *DatagoClient) Start() {
c.context, c.cancel = context.WithCancel(context.Background())
}

debug.SetGCPercent(10) // Invoke GC 10x more often

vips.LoggingSettings(func(domain string, level vips.LogLevel, msg string) {
fmt.Println(domain, level, msg)
}, vips.LogLevelWarning)
vips.Startup(nil) // Initialize the vips library, image processing backend

// Report panics in the background goroutines
defer func() {
if r := recover(); r != nil {
Expand Down
6 changes: 4 additions & 2 deletions tests/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func TestClientNoStop(t *testing.T) {
client := datago.GetClient(clientConfig)
client.Start()
_ = client.GetSample()

}

func TestMoreThanBufferSize(t *testing.T) {
Expand All @@ -72,6 +71,7 @@ func TestMoreThanBufferSize(t *testing.T) {
if client.GetSample().ID == "" {
t.Errorf("GetSample returned an unexpected error")
}
client.Stop()
}

func TestFetchImage(t *testing.T) {
Expand Down Expand Up @@ -220,6 +220,7 @@ func TestImageBufferCompression(t *testing.T) {
if err != nil {
t.Errorf("Error decoding mask buffer")
}
client.Stop()
}

func TestStrings(t *testing.T) {
Expand Down Expand Up @@ -255,11 +256,12 @@ func TestRanks(t *testing.T) {
clientConfig.SourceConfig = dbConfig

client_0 := datago.GetClient(clientConfig)
client_0.Start()

dbConfig.Rank = 1
clientConfig.SourceConfig = dbConfig
client_1 := datago.GetClient(clientConfig)

client_0.Start()
client_1.Start()

samples_0 := make(map[string]int)
Expand Down

0 comments on commit 99d5af7

Please sign in to comment.