<commit_before>package env

import (
	"os/user"
	"testing"
)

var (
	//newGroup := Group{
	//"newGroup",
	//dummyPassword,
	//}

	dummyUser = User{
		Name:    "dummyUser",
		HomeDir: "/home/dummyUser",
	}
)

func TestNewUser(t *testing.T) {
	err := NewUser(dummyUser)
	if err != nil {
		t.Fatalf("user creation failed -> %v", err)
	}

	newUser, err := user.Lookup("dummyUser")
	if err != nil {
		t.Fatalf("user look-up failed -> %v", err)
	}

	if newUser.Username != "dummyUser" {
		t.Errorf("user name discrepancy -> %v", newUser.Username)
	}
}
<commit_msg>Add User tests for Name Switch Services information parsing<commit_after>package env

import "testing"

func TestPasswdDatabaseEntryRetrieval(t *testing.T) {
	root, err := GetUser("root")
	if err != nil {
		t.Fatalf("user entry retrieval error -> %v", err)
	}

	if root.Name != "root" {
		t.Fatalf("wrong user name for root account")
	}

	if root.UID != "0" {
		t.Fatalf("wrong user ID for root account")
	}

	if root.PrimaryGroup != "0" {
		t.Fatalf("wrong group ID for root account")
	}

	if root.HomeDir != "/root" {
		t.Fatalf("wrong home directory for root account")
	}

	if root.IsSystemAccount != true {
		t.Fatalf("wrong account type for root account")
	}
}

func TestShadowDatabaseEntryRetrieval(t *testing.T) {
	root, err := GetUserShadowEntry("root")
	if err != nil {
		t.Fatalf("user entry retrieval error -> %v", err)
	}

	if root.PasswordHash != "locked" {
		t.Fatalf("wrong user name for root account")
	}
}

func TestCreateNewUser(t *testing.T) {
	dummyUser := User{
		Name:              "dummyUser",
		HomeDir:           "/etc",
		Description:       "This is a description.",
		DontCreateHomeDir: true,
	}

	err := CreateNewUser(dummyUser)
	if err != nil {
		t.Fatalf("user creation failed -> %v", err)
	}

	newUser, err := GetUser("dummyUser")
	if err != nil {
		t.Fatalf("user look-up failed -> %v", err)
	}

	if newUser.Name != "dummyUser" {
		t.Errorf("user name discrepancy -> %v", newUser.Name)
	}

	if newUser.Description != "This is a description." {
		t.Errorf("user name discrepancy -> %v", newUser.Name)
	}
}

func TestSetUserPassword(t *testing.T) {
	root, err := GetUser("root")
	if err != nil {
		t.Fatalf("user look-up failed -> %v", err)
	}

	root.SetPassword("<PASSWORD>")

	rootShadowEntry, err := GetUserShadowEntry("root")
	if err != nil {
		t.Fatalf("shadow entry retrieval failed -> %v", err)
	}

	if rootShadowEntry.PasswordHash != "<PASSWORD>" {
		t.Fatal("setting user password failed for root")
	}
}

{'fraction_non_alphanumeric': 0.15913634546181527, 'fraction_numerical': 0.0007996801279488205, 'mean_word_length': 3.5, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, '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': '904612', 'n_tokens_mistral': 930, 'n_tokens_neox': 887, 'n_words': 236}