From 97964650186f3c3863f176cbe9e44f963545bbde Mon Sep 17 00:00:00 2001 From: scruzin Date: Thu, 10 Jan 2019 12:51:18 +1030 Subject: [PATCH] Exit if RTMP_TEST_KEY not defined. --- rtmp/rtmp_test.go | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/rtmp/rtmp_test.go b/rtmp/rtmp_test.go index ea5f687c..2dc6781d 100644 --- a/rtmp/rtmp_test.go +++ b/rtmp/rtmp_test.go @@ -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) }