package tmobile_test

import (
	"os"
	"testing"

	"github.com/fiskerinc/cloud-services/pkg/tmobile"
)

func TestICCIDFilter(t *testing.T){
	// If there is a filter, on the listed iccids should work
	err := os.Setenv("SMS_ICCID_FILTER_LIST", "iccid1,iccid2, iccid3")
	if err != nil {
		t.Error(err)
		return
	}

	filter := tmobile.InitFilter()
	send := filter.ShouldSend("iccid2")
	if !send {
		t.Fail()
		return
	}
	
	send = filter.ShouldSend("iccid3")
	if !send {
		t.Fail()
		return
	}

	send = filter.ShouldSend("notInList")
	if send {
		t.Fail()
		return
	}

	// if the filter is empty, all should be sent
	filter.SetFilter([]string{})
	send = filter.ShouldSend("iccid2")
	if !send {
		t.Fail()
		return
	}
}