Skip to content

Commit

Permalink
Add useragent test for archive pool
Browse files Browse the repository at this point in the history
  • Loading branch information
chowbao committed Jan 18, 2024
1 parent 61c90a9 commit a234e65
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions historyarchive/archive_pool_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2016 Stellar Development Foundation and contributors. Licensed
// under the Apache License, Version 2.0. See the COPYING file at the root
// of this distribution or at http://www.apache.org/licenses/LICENSE-2.0

package historyarchive

import (
"net/http"
"net/http/httptest"
"testing"

"github.com/stellar/go/support/storage"
"github.com/stretchr/testify/assert"
)

func TestConfiguresHttpUserAgentForArchivePool(t *testing.T) {
var userAgent string
var archiveURLs []string
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
userAgent = r.Header["User-Agent"][0]
w.WriteHeader(http.StatusOK)
}))
defer server.Close()
archiveURLs = append(archiveURLs, server.URL)

archiveOptions := ArchiveOptions{
ConnectOptions: storage.ConnectOptions{
UserAgent: "uatest",
},
}

archivePool, err := NewArchivePool(archiveURLs, archiveOptions)
assert.NoError(t, err)

ok, err := archivePool.BucketExists(EmptyXdrArrayHash())
assert.True(t, ok)
assert.NoError(t, err)
assert.Equal(t, userAgent, "uatest")
}

0 comments on commit a234e65

Please sign in to comment.