package collect import ( "context" "testing" "github.com/host-uk/core/pkg/io" "github.com/stretchr/testify/assert" ) func TestBitcoinTalkCollector_Name_Good(t *testing.T) { b := &BitcoinTalkCollector{TopicID: "12345"} assert.Equal(t, "bitcointalk:12345", b.Name()) } func TestBitcoinTalkCollector_Name_Good_URL(t *testing.T) { b := &BitcoinTalkCollector{URL: "https://bitcointalk.org/index.php?topic=12345.0"} assert.Equal(t, "bitcointalk:url", b.Name()) } func TestBitcoinTalkCollector_Collect_Bad_NoTopicID(t *testing.T) { m := io.NewMockMedium() cfg := NewConfigWithMedium(m, "/output") b := &BitcoinTalkCollector{} _, err := b.Collect(context.Background(), cfg) assert.Error(t, err) } func TestBitcoinTalkCollector_Collect_Good_DryRun(t *testing.T) { m := io.NewMockMedium() cfg := NewConfigWithMedium(m, "/output") cfg.DryRun = true b := &BitcoinTalkCollector{TopicID: "12345"} result, err := b.Collect(context.Background(), cfg) assert.NoError(t, err) assert.Equal(t, 0, result.Items) } func TestParsePostsFromHTML_Good(t *testing.T) { sampleHTML := `