-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathguid_test.go
More file actions
33 lines (30 loc) · 805 Bytes
/
guid_test.go
File metadata and controls
33 lines (30 loc) · 805 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
// Copyright (C) 2021 Charalampos Mitsakis (go.mitsakis.org/tmpfox)
// Licensed under the EUPL-1.2-or-later
package main
import (
"context"
"net/http"
"testing"
"time"
)
func TestExtractGuidFromHTML(t *testing.T) {
tr := &http.Transport{}
defer tr.CloseIdleConnections()
client := &http.Client{
Transport: tr,
Timeout: 30 * time.Second,
}
addonSlug := "ublock-origin"
addonPageURL := "https://addons.mozilla.org/en-US/firefox/addon/" + addonSlug + "/"
pageHTML, err := openURLHTML(context.Background(), client, addonPageURL)
if err != nil {
t.Fatalf("cannot open url %s - error: %s", addonPageURL, err)
}
guid, err := extractGUIDFromHTML(pageHTML)
if err != nil {
t.Fatalf("failed: %s\n", err)
}
if guid != "uBlock0@raymondhill.net" {
t.Fatalf("wrong guid: %s", guid)
}
}