forked from prebid/prebid-server
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
155 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package pubstack |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package eventchannel | ||
|
||
import ( | ||
"io/ioutil" | ||
"net/http" | ||
"net/http/httptest" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestNewHttpSender(t *testing.T) { | ||
requestBody := make([]byte, 10) | ||
server := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { | ||
defer req.Body.Close() | ||
requestBody, _ = ioutil.ReadAll(req.Body) | ||
res.WriteHeader(200) | ||
})) | ||
|
||
defer server.Close() | ||
|
||
sender := NewHttpSender(server.Client(), server.URL) | ||
err := sender([]byte("message")) | ||
|
||
assert.Equal(t, requestBody, []byte("message")) | ||
assert.Nil(t, err) | ||
} | ||
|
||
func TestNewHttpSender_Error(t *testing.T) { | ||
server := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { | ||
res.WriteHeader(400) | ||
})) | ||
|
||
defer server.Close() | ||
|
||
sender := NewHttpSender(server.Client(), server.URL) | ||
err := sender([]byte("message")) | ||
|
||
assert.NotNil(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package helpers | ||
|
||
import ( | ||
"github.com/mxmCherry/openrtb" | ||
"github.com/prebid/prebid-server/analytics" | ||
"github.com/prebid/prebid-server/usersync" | ||
"net/http" | ||
"testing" | ||
) | ||
|
||
func TestJsonifyAuctionObject(t *testing.T) { | ||
ao := &analytics.AuctionObject{ | ||
Status: http.StatusOK, | ||
} | ||
if _, err := JsonifyAuctionObject(ao, "scopeId"); err != nil { | ||
t.Fail() | ||
} | ||
|
||
} | ||
|
||
func TestJsonifyVideoObject(t *testing.T) { | ||
vo := &analytics.VideoObject{ | ||
Status: http.StatusOK, | ||
} | ||
if _, err := JsonifyVideoObject(vo, "scopeId"); err != nil { | ||
t.Fail() | ||
} | ||
} | ||
|
||
func TestJsonifyCookieSync(t *testing.T) { | ||
cso := &analytics.CookieSyncObject{ | ||
Status: http.StatusOK, | ||
BidderStatus: []*usersync.CookieSyncBidders{}, | ||
} | ||
if _, err := JsonifyCookieSync(cso, "scopeId"); err != nil { | ||
t.Fail() | ||
} | ||
} | ||
|
||
func TestJsonifySetUIDObject(t *testing.T) { | ||
so := &analytics.SetUIDObject{ | ||
Status: http.StatusOK, | ||
Bidder: "any-bidder", | ||
UID: "uid string", | ||
} | ||
if _, err := JsonifySetUIDObject(so, "scopeId"); err != nil { | ||
t.Fail() | ||
} | ||
} | ||
|
||
func TestJsonifyAmpObject(t *testing.T) { | ||
ao := &analytics.AmpObject{ | ||
Status: http.StatusOK, | ||
Errors: make([]error, 0), | ||
AuctionResponse: &openrtb.BidResponse{}, | ||
AmpTargetingValues: map[string]string{}, | ||
} | ||
if _, err := JsonifyAmpObject(ao, "scopeId"); err != nil { | ||
t.Fail() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters