<commit_before>package iapi

import (
	"testing"
)

func TestServices(t *testing.T) {
	icingaServer := Server{"root", "", "https://127.0.0.1:5665/v1", true, nil}
	testHostName := "c1-mysql-1"
	_, err := icingaServer.CreateHost(testHostName, "127.0.0.1", "hostalive", nil, nil, nil)
	if err != nil {
		t.Error(err)
	}
	defer func() {
		_ = icingaServer.DeleteHost(testHostName)
	}()

	t.Run("CreateService", func(t *testing.T) {
		// Try and create a service for a host that does not exist.
		// Should fail with an error about the host not existing.
		t.Run("HostDoNotExists", func(t *testing.T) {
			nonExistingHost := "c1-host-dne-1"
			servicename := "ssh"
			checkCommand := "ssh"

			_, err := icingaServer.CreateService(servicename, nonExistingHost, checkCommand, nil, nil)
			if err == nil {
				t.Error("ServiceHostDoNotExists: expected error returning, got nil")
			}
		})

		// Create a host and service via the API
		t.Run("HostAndService", func(t *testing.T) {
			servicename := "ssh"
			checkCommand := "ssh"

			_, err := icingaServer.CreateService(servicename, testHostName, checkCommand, nil, nil)
			if err != nil {
				t.Errorf("Error : Failed to create service %s!%s : %s", testHostName, servicename, err)<commit_msg>services: use env var for icinga password<commit_after>package iapi

import (
	"testing"
)

func TestServices(t *testing.T) {
	icingaServer := Server{"root", ICINGA2_API_PASSWORD, "https://127.0.0.1:5665/v1", true, nil}
	testHostName := "c1-mysql-1"
	_, err := icingaServer.CreateHost(testHostName, "127.0.0.1", "hostalive", nil, nil, nil)
	if err != nil {
		t.Error(err)
	}
	defer func() {
		_ = icingaServer.DeleteHost(testHostName)
	}()

	t.Run("CreateService", func(t *testing.T) {
		// Try and create a service for a host that does not exist.
		// Should fail with an error about the host not existing.
		t.Run("HostDoNotExists", func(t *testing.T) {
			nonExistingHost := "c1-host-dne-1"
			servicename := "ssh"
			checkCommand := "ssh"

			_, err := icingaServer.CreateService(servicename, nonExistingHost, checkCommand, nil, nil)
			if err == nil {
				t.Error("ServiceHostDoNotExists: expected error returning, got nil")
			}
		})

		// Create a host and service via the API
		t.Run("HostAndService", func(t *testing.T) {
			servicename := "ssh"
			checkCommand := "ssh"

			_, err := icingaServer.CreateService(servicename, testHostName, checkCommand, nil, nil)
			if err != nil {
				t.Errorf("Error : Failed to create service %s!%s : %s", testHostName, servicename, err)
{'fraction_non_alphanumeric': 0.14733915806195394, 'fraction_numerical': 0.017077045274027005, 'mean_word_length': 3.9103313840155947, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '1032329', 'n_tokens_mistral': 995, 'n_tokens_neox': 893, 'n_words': 228}