<commit_before>package model

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestGetOrCreateServiceShouldCreateService(t *testing.T) {
	service, err := GetOrCreateService(db, "lebron-james")
	assert.Nil(t, err)
	assert.NotNil(t, service)
	assert.Equal(t, "lebron-james", service.Name)

	var check Service
	db.Where("name = ?", "lebron-james").First(&check)
	assert.Equal(t, "lebron-james", check.Name)
}<commit_msg>Add test for no duplicate services<commit_after>package model

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestGetOrCreateServiceShouldCreateService(t *testing.T) {
	service, err := GetOrCreateService(db, "lebron-james")
	assert.Nil(t, err)
	assert.NotNil(t, service)
	assert.Equal(t, "lebron-james", service.Name)

	var check Service
	db.Where("name = ?", "lebron-james").First(&check)
	assert.Equal(t, "lebron-james", check.Name)
}

func TestGetOrCreateServiceShouldNotCreateDuplicateNames(t *testing.T) {
	service, err := GetOrCreateService(db, "foo")
	assert.Nil(t, err)
	assert.NotNil(t, service)
	assert.Equal(t, "foo", service.Name)

	service, err = GetOrCreateService(db, "foo")
	assert.Nil(t, err)
	assert.NotNil(t, service)
	assert.Equal(t, "foo", service.Name)

	var services []Service
	db.Where("name = ?", "foo").Find(&services)
	assert.Equal(t, 1, len(services))
}
{'fraction_non_alphanumeric': 0.1601796407185629, 'fraction_numerical': 0.0007485029940119761, 'mean_word_length': 5.786802030456853, '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': '6398798', 'n_tokens_mistral': 510, 'n_tokens_neox': 495, 'n_words': 92}