Remove STEMtv client since the service has been discontinued.

This commit is contained in:
Patrick Fairbank
2018-09-23 12:21:32 -07:00
parent 36c7c56212
commit f8466f743a
9 changed files with 28 additions and 126 deletions

View File

@@ -1,35 +0,0 @@
// Copyright 2016 Team 254. All Rights Reserved.
// Author: pat@patfairbank.com (Patrick Fairbank)
//
// Methods for publishing match video split information to STEMtv.
package partner
import (
"fmt"
"github.com/Team254/cheesy-arena/model"
"net/http"
"time"
)
type StemTvClient struct {
BaseUrl string
eventCode string
}
const (
stemTvBaseUrl = "http://52.21.72.74:5000"
preMatchPaddingSec = 5
postScoreDisplayPaddingSec = 10
)
func NewStemTvClient(eventCode string) *StemTvClient {
return &StemTvClient{stemTvBaseUrl, eventCode}
}
func (client *StemTvClient) PublishMatchVideoSplit(match *model.Match, scoreDisplayTime time.Time) error {
url := fmt.Sprintf("%s/event/api/v1.0/%s/%s/split/%d,%d", client.BaseUrl, client.eventCode, match.TbaCode(),
match.StartedAt.Unix()-preMatchPaddingSec, scoreDisplayTime.Unix()+postScoreDisplayPaddingSec)
_, err := http.Get(url)
return err
}

View File

@@ -1,29 +0,0 @@
// Copyright 2016 Team 254. All Rights Reserved.
// Author: pat@patfairbank.com (Patrick Fairbank)
package partner
import (
"github.com/Team254/cheesy-arena/model"
"github.com/stretchr/testify/assert"
"net/http"
"net/http/httptest"
"testing"
"time"
)
func TestPublishMatchVideoSplit(t *testing.T) {
// Mock the STEMtv server.
stemTvServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, "/event/api/v1.0/my_event_code/qm254/split/981187501,981187690", r.URL.String())
}))
defer stemTvServer.Close()
client := NewStemTvClient("my_event_code")
client.BaseUrl = stemTvServer.URL
matchStartedTime, _ := time.Parse("2006-01-02 15:04:05 -0700", "2001-02-03 04:05:06 -0400")
match := &model.Match{Type: "qualification", DisplayName: "254", StartedAt: matchStartedTime}
scoreDisplayTime, _ := time.Parse("2006-01-02 15:04:05 -0700", "2001-02-03 04:08:00 -0400")
assert.Nil(t, client.PublishMatchVideoSplit(match, scoreDisplayTime))
}