<commit_before>package bpmon

import (
	"testing"
	"time"

	"github.com/unprofession-al/bpmon/status"
)

type bpTestSet struct {
	bp     BP
	status status.Status
}

var allDayLong = Availability{
	time.Monday:    AvailabilityTime{AllDay: true},
	time.Tuesday:   AvailabilityTime{AllDay: true},
	time.Wednesday: AvailabilityTime{AllDay: true},
	time.Thursday:  AvailabilityTime{AllDay: true},
	time.Friday:    AvailabilityTime{AllDay: true},
	time.Saturday:  AvailabilityTime{AllDay: true},
	time.Sunday:    AvailabilityTime{AllDay: true},
}

var BpTestSets = []bpTestSet{
	{
		bp: BP{
			Name:         "TestBP",
			Id:           "test_bp",
			Availability: allDayLong,
			Kpis: []KPI{
				KPI{
					Name:      "TestKPI",
					Id:        "test_kpi",
					Operation: "OR",
					Services: []Service{
						Service{"Host", "good"},
					},
				},
			},
		},
		status: status.Ok,
	},
}

func TestBusinessProcess(t *testing.T) {
	ssp := SSPMock{}
	for _, bp := range BpTestSets {
		rs := bp.bp.Status(ssp, ssp.DefaultRules())
		if rs.Status != bp.status {
			t.Errorf("Expected status to be '%s', got '%s'", bp.status, rs.Status)
		}
	}
}

type svcTestSet struct {
	svc         Service
	status      status.Status
	vals        map[string]bool
	errExpected bool
}

var SvcTestSets = []svcTestSet{
	{
		svc:         Service{"Host", "good"},
		status:      status.Ok,
		errExpected: false,
	},
	{
		svc:         Service{"Host", "bad"},
		status:      status.Nok,
		errExpected: false,
	},
	{
		svc:         Service{"Host", "unknown"},
		status:      status.Unknown,
		errExpected: false,
	},
	{
		svc:         Service{"Host", "error"},
		status:      status.Ok,
		errExpected: true,
	},
}

func TestServices(t *testing.T) {
	ssp := SSPMock{}
	for _, s := range SvcTestSets {
		rs := s.svc.Status(ssp, ssp.DefaultRules())
		if s.errExpected && rs.Err == nil {<commit_msg>fixed broken tests<commit_after>package bpmon

import (
	"testing"
	"time"

	"github.com/unprofession-al/bpmon/status"
)

type bpTestSet struct {
	bp     BP
	status status.Status
}

var allDayLong = Availability{
	time.Monday:    AvailabilityTime{AllDay: true},
	time.Tuesday:   AvailabilityTime{AllDay: true},
	time.Wednesday: AvailabilityTime{AllDay: true},
	time.Thursday:  AvailabilityTime{AllDay: true},
	time.Friday:    AvailabilityTime{AllDay: true},
	time.Saturday:  AvailabilityTime{AllDay: true},
	time.Sunday:    AvailabilityTime{AllDay: true},
}

var BpTestSets = []bpTestSet{
	{
		bp: BP{
			Name:         "TestBP",
			Id:           "test_bp",
			Availability: allDayLong,
			Kpis: []KPI{
				KPI{
					Name:      "TestKPI",
					Id:        "test_kpi",
					Operation: "OR",
					Services: []Service{
						Service{Host: "Host", Service: "good"},
					},
				},
			},
		},
		status: status.Ok,
	},
}

func TestBusinessProcess(t *testing.T) {
	ssp := SSPMock{}
	pp := PPMock{}
	for _, bp := range BpTestSets {
		rs := bp.bp.Status(ssp, pp, ssp.DefaultRules())
		if rs.Status != bp.status {
			t.Errorf("Expected status to be '%s', got '%s'", bp.status, rs.Status)
		}
	}
}

type svcTestSet struct {
	svc         Service
	status      status.Status
	vals        map[string]bool
	errExpected bool
}

var SvcTestSets = []svcTestSet{
	{
		svc:         Service{Host: "Host", Service: "good"},
		status:      status.Ok,
		errExpected: false,
	},
	{
		svc:         Service{Host: "Host", Service: "bad"},
		status:      status.Nok,
		errExpected: false,
	},
	{
		svc:         Service{Host: "Host", Service: "unknown"},
		status:      status.Unknown,
		errExpected: false,
	},
	{
		svc:         Service{Host: "Host", Service: "error"},
		status:      status.Ok,
		errExpected: true,
	},
}

func TestServices(t *testing.T) {
	pp := PPMock{}
	ssp := SSPMock{}
	for _, s := range SvcTestSets {
		rs := s.svc.Status(ssp, pp, ssp.DefaultRules())
		if s.errExpected && rs.Err == nil {
{'fraction_non_alphanumeric': 0.15052083333333333, 'fraction_numerical': 0.0, 'mean_word_length': 2.9074262461851474, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6829582', 'n_tokens_mistral': 1578, 'n_tokens_neox': 1403, 'n_words': 308}