Skip to content

Commit

Permalink
db/redis: add structs to stub_test to avoid db dependency on redis st…
Browse files Browse the repository at this point in the history
…orage
  • Loading branch information
flavioribeiro committed Nov 14, 2016
1 parent a70a602 commit d6a1595
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 13 deletions.
24 changes: 11 additions & 13 deletions db/redis/storage/redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"sync"
"testing"
"time"

"github.com/NYTimes/video-transcoding-api/db"
)

func TestRedisClientRedisDefaultOptions(t *testing.T) {
Expand Down Expand Up @@ -242,20 +240,20 @@ func TestFieldMap(t *testing.T) {
expected map[string]string
}{
{
"db.Job",
db.Job{
"Job",
Job{
ID: "job1",
ProviderJobID: "123abc",
SourceMedia: "http://nyt.net/source_here.mp4",
ProviderName: "encoding.com",
StreamingParams: db.StreamingParams{
StreamingParams: StreamingParams{
SegmentDuration: 10,
Protocol: "hls",
PlaylistFileName: "hls/playlist.m3u8",
},
Outputs: []db.TranscodeOutput{
{Preset: db.PresetMap{Name: "preset-1"}, FileName: "output1.m3u8"},
{Preset: db.PresetMap{Name: "preset-2"}, FileName: "output2.m3u8"},
Outputs: []TranscodeOutput{
{Preset: PresetMap{Name: "preset-1"}, FileName: "output1.m3u8"},
{Preset: PresetMap{Name: "preset-2"}, FileName: "output2.m3u8"},
},
},
map[string]string{
Expand All @@ -270,15 +268,15 @@ func TestFieldMap(t *testing.T) {
},
},
{
"db.LocalPreset",
db.LocalPreset{
"LocalPreset",
LocalPreset{
Name: "this-is-a-localpreset",
Preset: db.Preset{
Preset: Preset{
Name: "test",
Description: "test preset",
Container: "mp4",
RateControl: "VBR",
Video: db.VideoPreset{
Video: VideoPreset{
Profile: "main",
ProfileLevel: "3.1",
Width: "640",
Expand All @@ -289,7 +287,7 @@ func TestFieldMap(t *testing.T) {
GopMode: "fixed",
InterlaceMode: "progressive",
},
Audio: db.AudioPreset{
Audio: AudioPreset{
Codec: "aac",
Bitrate: "64000",
},
Expand Down
60 changes: 60 additions & 0 deletions db/redis/storage/stub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,63 @@ type InvalidStruct struct {
type InvalidInnerStruct struct {
Data map[string]int `redis-hash:"data,expand"`
}

type Job struct {
ID string `redis-hash:"jobID"`
ProviderName string `redis-hash:"providerName"`
ProviderJobID string `redis-hash:"providerJobID"`
StreamingParams StreamingParams `redis-hash:"streamingparams,expand"`
CreationTime time.Time `redis-hash:"creationTime"`
SourceMedia string `redis-hash:"source"`
Outputs []TranscodeOutput `redis-hash:"-"`
}

type TranscodeOutput struct {
Preset PresetMap `redis-hash:"presetmap,expand"`
FileName string `redis-hash:"filename"`
}

type PresetMap struct {
Name string `redis-hash:"presetmap_name"`
}

type OutputOptions struct {
Extension string `redis-hash:"extension"`
}

type StreamingParams struct {
SegmentDuration uint `redis-hash:"segmentDuration"`
Protocol string `redis-hash:"protocol"`
PlaylistFileName string `redis-hash:"playlistFileName"`
}

type LocalPreset struct {
Name string `redis-hash:"-"`
Preset Preset `redis-hash:"preset,expand"`
}

type Preset struct {
Name string `redis-hash:"name"`
Description string `redis-hash:"description,omitempty"`
Container string `redis-hash:"container,omitempty"`
RateControl string `redis-hash:"ratecontrol,omitempty"`
Video VideoPreset `redis-hash:"video,expand"`
Audio AudioPreset `redis-hash:"audio,expand"`
}

type VideoPreset struct {
Profile string `redis-hash:"profile,omitempty"`
ProfileLevel string `redis-hash:"profilelevel,omitempty"`
Width string `redis-hash:"width,omitempty"`
Height string `redis-hash:"height,omitempty"`
Codec string `redis-hash:"codec,omitempty"`
Bitrate string `redis-hash:"bitrate,omitempty"`
GopSize string `redis-hash:"gopsize,omitempty"`
GopMode string `redis-hash:"gopmode,omitempty"`
InterlaceMode string `redis-hash:"interlacemode,omitempty"`
}

type AudioPreset struct {
Codec string `redis-hash:"codec,omitempty"`
Bitrate string `redis-hash:"bitrate,omitempty"`
}

0 comments on commit d6a1595

Please sign in to comment.