<commit_before>package store

import (
  "testing"
  "strings"
  "os"
  osuser "os/user"
  "path"
)

var DIR = func() string {
  dir := "."
  user, err := osuser.Current()
  if err == nil {
    dir = user.HomeDir
  }

  // WARNING: This directory is completely deleted if it exists. Don't mistype.
  return path.Join(dir, "VoleTest")
}()

var userStore = &UserStore{
  Path: DIR,
  Version: "v1",
}

func assertFileOrDir(t *testing.T, myUserPath string) {
  _, err := os.Stat(myUserPath)
  if err != nil {
    t.Error(err)
  }
}

/**
 * Setup the test directory
 */
func TestSetup(t *testing.T) {
  os.RemoveAll(userStore.Path)
  os.MkdirAll(userStore.Path, 0755)
}

func TestCreateUser(t *testing.T) {
  user := userStore.NewUser("first_user", "<EMAIL>")

  if len(user.Id) != 36 {
    t.Error("UUID wasn't set to a 36 character string")
  }
  if user.Name != "first_user" {
    t.Error("User name wasn't set correctly")
  }
  if user.Email != "<EMAIL>" {
    t.Error("Email not set correctly")
  }
  if !user.IsMyUser {
    t.Error("IsMyUser not set to true")
  }
  if !strings.Contains(user.Avatar, "https://gravatar.com/") {
    t.Error("Gravatar not being set correctly")
  }
  if !strings.Contains(user.FullPath, user.Name + "_" + user.Id) {
    t.Error("User path location not set correctly")
  }
  if !strings.Contains(user.UserJsonPath, user.Name + "_" + user.Id) {
    t.Error("User json path location not set correctly")
  }
  //t.Log(user)
}

func TestSaveUser(t *testing.T) {
  user := userStore.NewUser("first_user", "<EMAIL>")

  if err := userStore.SetMyUser(user); err != nil {
    t.Error(err)
  }
  assertFileOrDir(t, path.Join(userStore.Path, "my_user"))

  if err := user.Save(); err != nil {
    t.Error(err)
  }
  if user.IsMyUser != true {<commit_msg>Return polling<commit_after>package store

import (
  "testing"
  "strings"
  "os"
  osuser "os/user"
  "path"
)

var DIR = func() string {
  dir := "."
  user, err := osuser.Current()
  if err == nil {
    dir = user.HomeDir
  }

  // WARNING: This directory is completely deleted if it exists. Don't mistype.
  return path.Join(dir, "VoleTest")
}()

var userStore = &UserStore{
  Path: DIR,
  Version: "v1",
}

func assertFileOrDir(t *testing.T, myUserPath string) {
  _, err := os.Stat(myUserPath)
  if err != nil {
    t.Error(err)
  }
}

/**
 * Setup the test directory
 */
func TestSetup(t *testing.T) {
  os.RemoveAll(userStore.Path)
  os.MkdirAll(userStore.Path, 0755)
}

func TestCreateUser(t *testing.T) {
  user := userStore.NewUser("first_user", "<EMAIL>")

  if len(user.Id) != 36 {
    t.Error("UUID wasn't set to a 36 character string")
  }
  if user.Name != "first_user" {
    t.Error("User name wasn't set correctly")
  }
  if user.Email != "<EMAIL>" {
    t.Error("Email not set correctly")
  }
  if !user.IsMyUser {
    t.Error("IsMyUser not set to true")
  }
  if !strings.Contains(user.Avatar, "https://gravatar.com/") {
    t.Error("Gravatar not being set correctly")
  }
  if !strings.Contains(user.FullPath, user.Name + "_" + user.Id) {
    t.Error("User path location not set correctly")
  }
  if !strings.Contains(user.UserJsonPath, user.Name + "_" + user.Id) {
    t.Error("User json path location not set correctly")
  }
}

func TestSaveUser(t *testing.T) {
  user := userStore.NewUser("first_user", "<EMAIL>")

  if err := userStore.SetMyUser(user); err != nil {
    t.Error(err)
  }
  assertFileOrDir(t, path.Join(userStore.Path, "my_user"))

  if err := user.Save(); err != nil {
    t.Error(err)
  }
  if user.IsMyUser != true {
{'fraction_non_alphanumeric': 0.16265912305516267, 'fraction_numerical': 0.005091937765205092, 'mean_word_length': 3.25, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '3192311', 'n_tokens_mistral': 1342, 'n_tokens_neox': 1314, 'n_words': 314}