package qospolicy

import "testing"

var qosPolicies = ListQoSPolicies{
	Data: []ItemQoSPolicy{
		{
			ID:          1,
			AccountID:   1,
			Name:        "qos1",
			Description: "some desc",
			Status:      "ENABLED",
		},
		{
			ID:          3,
			AccountID:   3,
			Name:        "qos3",
			Description: "some desc",
			Status:      "ENABLED",
		},
		{
			ID:          5,
			AccountID:   3,
			Name:        "qos5",
			Description: "some other desc",
			Status:      "DISABLED",
		},
	},
	EntryCount: 3,
}

func TestFilterByID(t *testing.T) {
	actual := qosPolicies.FilterByID(1).FindOne()
	if actual.ID != 1 {
		t.Fatal("expected ID 1, found: ", actual.ID)
	}
}

func TestFilterByName(t *testing.T) {
	actual := qosPolicies.FilterByName("qos3").FindOne()
	if actual.Name != "qos3" {
		t.Fatal("expected Name qos3, found: ", actual.Name)
	}
}

func TestFilterByDescription(t *testing.T) {
	actual := qosPolicies.FilterByDescription("some desc")

	if len(actual.Data) != 2 {
		t.Fatal("expected 2 found, actual: ", len(actual.Data))
	}

	for _, item := range actual.Data {
		if item.Description != "some desc" {
			t.Fatal("expected Description 'some desc', found: ", item.Description)
		}
	}
}

func TestFilterByAccountID(t *testing.T) {
	actual := qosPolicies.FilterByAccountID(1).FindOne()
	if actual.AccountID != 1 {
		t.Fatal("expected AccountID 1, found: ", actual.AccountID)
	}
}

func TestFilterByStatus(t *testing.T) {
	actual := qosPolicies.FilterByStatus("DISABLED").FindOne()
	if actual.Status != "DISABLED" {
		t.Fatal("expected Status DISABLED, found: ", actual.Status)
	}
}
