Skip to content

Commit

Permalink
Changes the Zencoder wrapper to use the job status found in the jobDe…
Browse files Browse the repository at this point in the history
…tails for the JobState
  • Loading branch information
scentless-apprentice committed Jan 25, 2017
1 parent 58b5e83 commit f32e347
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
2 changes: 1 addition & 1 deletion provider/zencoder/zencoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func (z *zencoderProvider) JobStatus(job *db.Job) (*provider.JobStatus, error) {
return &provider.JobStatus{
ProviderName: Name,
ProviderJobID: job.ProviderJobID,
Status: z.statusMap(progress.State),
Status: z.statusMap(zencoder.JobState(jobDetails.Job.State)),
Progress: progress.JobProgress,
Output: jobOutputs,
SourceInfo: provider.SourceInfo{
Expand Down
5 changes: 5 additions & 0 deletions provider/zencoder/zencoder_fake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ func (z *FakeZencoder) GetJobProgress(id int64) (*zencoder.JobProgress, error) {
}

func (z *FakeZencoder) GetJobDetails(id int64) (*zencoder.JobDetails, error) {
state := "finished"
if id == 1234567890 || id == 837958345 {
state = "processing"
}
return &zencoder.JobDetails{
Job: &zencoder.Job{
State: state,
InputMediaFile: &zencoder.MediaFile{
Url: "http://nyt.net/input.mov",
Format: "mov",
Expand Down
45 changes: 44 additions & 1 deletion provider/zencoder/zencoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,49 @@ func TestZencoderJobStatus(t *testing.T) {
},
},
},
{
"837958345",
map[string]interface{}{
"providerName": "zencoder",
"providerJobId": "837958345",
"status": "started",
"progress": float64(100),
"sourceInfo": map[string]interface{}{
"duration": float64(50000000000),
"height": float64(1080),
"width": float64(1920),
"videoCodec": "ProRes422",
},
"providerStatus": map[string]interface{}{
"sourcefile": "http://nyt.net/input.mov",
"created": "2016-11-05T05:02:57Z",
"finished": "2016-11-05T05:02:57Z",
"updated": "2016-11-05T05:02:57Z",
"started": "2016-11-05T05:02:57Z",
},
"output": map[string]interface{}{
"destination": "/",
"files": []interface{}{
map[string]interface{}{
"path": "s3://mybucket/destination-dir/output1.mp4",
"container": "mp4",
"videoCodec": "h264",
"height": float64(1080),
"width": float64(1920),
"fileSize": float64(66885256),
},
map[string]interface{}{
"height": float64(720),
"width": float64(1080),
"fileSize": float64(92140022),
"path": "s3://mybucket/destination-dir/output2.webm",
"container": "webm",
"videoCodec": "vp8",
},
},
},
},
},
}
for _, test := range tests {
jobStatus, err := prov.JobStatus(&db.Job{ProviderJobID: test.ProviderJobID})
Expand All @@ -967,7 +1010,7 @@ func TestZencoderJobStatus(t *testing.T) {
}
if !reflect.DeepEqual(result, test.Expected) {
pretty.Fdiff(os.Stderr, test.Expected, result)
t.Errorf("Wrong JobStatus returned. Want %#v. Got %#v.", test.Expected, result)
t.Errorf("Wrong JobStatus returned. \nWant %#v.\n Got %#v.", test.Expected, result)
}
}
}
Expand Down

0 comments on commit f32e347

Please sign in to comment.