-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient_test.go
More file actions
37 lines (32 loc) · 771 Bytes
/
client_test.go
File metadata and controls
37 lines (32 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package gobalt
import (
"context"
"net/url"
"testing"
)
var (
urls = []string{
"https://x.com/tonystatovci/status/1856853985149227419?t=WuK-zVfde8WTofpdt7UBaQ&s=19",
}
)
func TestClient(t *testing.T) {
client := NewCobaltWithAPI("http://localhost:9000/")
for _, u := range urls {
pURL, _ := url.Parse(u)
t.Run(pURL.Host, func(t *testing.T) {
media, err := client.Post(context.Background(), PostRequest{URL: u})
if err != nil {
t.Errorf("failed to fetch media for %s url with error: %v", u, err)
}
if len(media.Filename) == 0 {
t.Error("filename was empty")
}
s, err := media.Stream(context.Background())
if err != nil {
t.Errorf("failed to stream media with error: %v", err)
return
}
defer s.Close()
})
}
}