package redis

import (
	"testing"

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

func TestInitSet(t *testing.T) {
	s := make(Set)

	numS := 0
	if len(s) != numS {
		t.Errorf(testhelper.TestErrorTemplate, "TestInitSet", numS, len(s))
	}
}

func TestSetAdd(t *testing.T) {
	s := make(Set)

	if ok := s.Add("TESTVIN123"); !ok {
		t.Errorf(testhelper.TestErrorTemplate, "TestSetAdd", true, ok)
	}

	numS := 1
	if len(s) != numS {
		t.Errorf(testhelper.TestErrorTemplate, "TestInitSet", numS, len(s))
	}
}

func TestSetAddError(t *testing.T) {
	s := make(Set)

	s.Add("TESTVIN123")
	if ok := s.Add("TESTVIN123"); ok {
		t.Errorf(testhelper.TestErrorTemplate, "TestSetAddError", false, ok)
	}

	numS := 1
	if len(s) != numS {
		t.Errorf(testhelper.TestErrorTemplate, "TestInitSet", numS, len(s))
	}
}

func TestSetRemove(t *testing.T) {
	s := make(Set)

	s.Add("TESTVIN123")
	if ok := s.Remove("TESTVIN123"); !ok {
		t.Errorf(testhelper.TestErrorTemplate, "TestSetRemove", true, ok)
	}

	numS := 0
	if len(s) != numS {
		t.Errorf(testhelper.TestErrorTemplate, "TestSetRemove", numS, len(s))
	}
}

func TestSetRemoveError(t *testing.T) {
	s := make(Set)

	if ok := s.Remove("TESTVIN123"); ok {
		t.Errorf(testhelper.TestErrorTemplate, "TestSetRemove", false, ok)
	}

	numS := 0
	if len(s) != numS {
		t.Errorf(testhelper.TestErrorTemplate, "TestSetRemove", numS, len(s))
	}
}
