From d6a1595fcae196a9aa7702cb310145ce5727f1ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Ribeiro?= Date: Mon, 14 Nov 2016 13:27:04 -0500 Subject: [PATCH] db/redis: add structs to stub_test to avoid db dependency on redis storage --- db/redis/storage/redis_test.go | 24 +++++++------- db/redis/storage/stub_test.go | 60 ++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 13 deletions(-) diff --git a/db/redis/storage/redis_test.go b/db/redis/storage/redis_test.go index 1a698a70..019105c7 100644 --- a/db/redis/storage/redis_test.go +++ b/db/redis/storage/redis_test.go @@ -11,8 +11,6 @@ import ( "sync" "testing" "time" - - "github.com/NYTimes/video-transcoding-api/db" ) func TestRedisClientRedisDefaultOptions(t *testing.T) { @@ -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{ @@ -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", @@ -289,7 +287,7 @@ func TestFieldMap(t *testing.T) { GopMode: "fixed", InterlaceMode: "progressive", }, - Audio: db.AudioPreset{ + Audio: AudioPreset{ Codec: "aac", Bitrate: "64000", }, diff --git a/db/redis/storage/stub_test.go b/db/redis/storage/stub_test.go index 19081e75..0cd7a2d4 100644 --- a/db/redis/storage/stub_test.go +++ b/db/redis/storage/stub_test.go @@ -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"` +}