mirror of https://bitbucket.org/ausocean/av.git
Exit if RTMP_TEST_KEY not defined.
This commit is contained in:
parent
3dbaa810fc
commit
9796465018
|
@ -29,10 +29,10 @@ package rtmp
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"runtime"
|
||||
"testing"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -81,9 +81,9 @@ func testLog(level int8, msg string, params ...interface{}) {
|
|||
|
||||
func TestKey(t *testing.T) {
|
||||
testLog(0, "TestKey")
|
||||
testKey := os.Getenv("RTMP_TEST_KEY")
|
||||
testKey = os.Getenv("RTMP_TEST_KEY")
|
||||
if testKey == "" {
|
||||
t.Errorf("RTMP_TEST_KEY environment variable not defined")
|
||||
fmt.Printf("RTMP_TEST_KEY environment variable not defined\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
testLog(0, "Testing against URL "+testBaseURL+testKey)
|
||||
|
@ -118,25 +118,35 @@ func TestSetupURL(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestOpen(t *testing.T) {
|
||||
testLog(0, "TestOpen")
|
||||
s := NewSession(testBaseURL+testKey, testTimeout, testLog)
|
||||
err := setupURL(s, s.url)
|
||||
if err != nil {
|
||||
t.Errorf("setupURL failed with error: %v", err)
|
||||
}
|
||||
s.enableWrite()
|
||||
err = s.Open()
|
||||
if err != nil {
|
||||
t.Errorf("connect failed with error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenClose(t *testing.T) {
|
||||
testLog(0, "TestOpenClose")
|
||||
s := NewSession(testBaseURL+testKey, testTimeout, testLog)
|
||||
err := s.Open()
|
||||
if err != nil {
|
||||
t.Errorf("Session.Open failed with error: %v", err)
|
||||
t.Errorf("Open failed with error: %v", err)
|
||||
return
|
||||
}
|
||||
err = s.Close()
|
||||
if err != nil {
|
||||
t.Errorf("Session.Close failed with error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFromFile(t *testing.T) {
|
||||
testLog(0, "TestFromFile")
|
||||
testFile := os.Getenv("RTMP_TEST_FILE")
|
||||
if testKey == "" {
|
||||
t.Errorf("RTMP_TEST_FILE environment variable not defined")
|
||||
fmt.Printf("RTMP_TEST_FILE environment variable not defined\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
s := NewSession(testBaseURL+testKey, testTimeout, testLog)
|
||||
|
@ -150,6 +160,7 @@ func TestFromFile(t *testing.T) {
|
|||
}
|
||||
// ToDo: rate limit writing
|
||||
n, err := s.Write(video)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Session.Write failed with error: %v", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue