Skip to content

Commit

Permalink
updates for v4 TT compatability (#59)
Browse files Browse the repository at this point in the history
* updates for v4 TT compatability

* add v4 post app identifier endpoint
* remove v4 app identifier visitor configs endpoint

* remove unused api v1 endpoint from fake server

* bump version
  • Loading branch information
samandmoore authored Jan 29, 2021
1 parent 48302ef commit c68e472
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SHELL = /bin/sh

VERSION=1.2.0
VERSION=1.3.0
BUILD=`git rev-parse HEAD`

LDFLAGS=-ldflags "-w -s \
Expand Down
16 changes: 8 additions & 8 deletions fakeserver/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ func (s *server) routes() {
"/api/v1/identifier",
postV1Identifier,
)
s.handlePost(
"/api/v4/apps/{a}/versions/{v}/builds/{b}/identifier",
postV4AppIdentifier,
)
s.handleGet(
"/api/v1/visitors/{id}",
getV1Visitor,
Expand Down Expand Up @@ -167,14 +171,6 @@ func (s *server) routes() {
"/api/v4/apps/{a}/versions/{v}/builds/{b}/visitors/{id}/config",
getV4AppVisitorConfig,
)
s.handleGet(
"/api/v1/apps/{a}/versions/{v}/builds/{b}/identifier_types/{t}/identifiers/{i}/visitor_config",
getV1AppVisitorConfig,
)
s.handleGet(
"/api/v4/apps/{a}/versions/{v}/builds/{b}/identifier_types/{t}/identifiers/{i}/visitor_config",
getV4AppVisitorConfig,
)
s.handleGet(
"/api/v1/split_details/{id}",
getV1SplitDetail,
Expand Down Expand Up @@ -271,6 +267,10 @@ func postV1Identifier(*http.Request) (interface{}, error) {
return map[string]v1Visitor{"visitor": visitor}, nil
}

func postV4AppIdentifier(*http.Request) (interface{}, error) {
return getV4AppVisitorConfig()
}

func getV1Visitor() (interface{}, error) {
assignments, err := fakeassignments.Read()
if err != nil {
Expand Down
8 changes: 6 additions & 2 deletions fakeserver/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,16 @@ func TestVisitorConfig(t *testing.T) {
})
}

func TestIdentifierVisitorConfig(t *testing.T) {
func TestAppIdentifier(t *testing.T) {
t.Run("it loads visitor config v4", func(t *testing.T) {
w := httptest.NewRecorder()
h := createHandler()

h.ServeHTTP(w, httptest.NewRequest("GET", "/api/v4/apps/foo/versions/1/builds/2020-01-02T03:04:05/identifier_types/user_id/identifiers/123/visitor_config", nil))
request := httptest.NewRequest("POST", "/api/v4/apps/foo/versions/1/builds/2020-01-02T03:04:05/identifier", nil)
request.Header.Add("Content-Type", "application/json")
request.Header.Add("Content-Length", "0")

h.ServeHTTP(w, request)

require.Equal(t, http.StatusOK, w.Code)

Expand Down

0 comments on commit c68e472

Please sign in to comment.