<commit_before>package bebber

import (
  "strings"
  "testing"
  "encoding/json"
  "gopkg.in/mgo.v2"
  "gopkg.in/mgo.v2/bson"
)

func Test_Search(t *testing.T) {
  doc := bson.M{"Song": bson.M{"RingOf": "Fire"}}
  session, err := mgo.Dial(TestDBServer)
  if err != nil {
    t.Fatal(err.Error())
  }
  defer session.Close()

  db := session.DB(TestDBName)
  defer db.DropDatabase()

  filesColl := db.C("files")
  err = filesColl.Insert(doc)
  if err != nil {
    t.Fatal(err.Error())
  }

  searchStr := `{"Song.RingOf": "Fire"}`
  tmp := Search(searchStr, db)
  result := *tmp

  if len(result) != 1 {
    t.Fatal("Expect len 1 was", len(result))
  }

  JSONBytes, err := json.Marshal(result)
  if err != nil {
    t.Fatal(err.Error())
  }

  expectJSONStr := `{"Song":{"RingOf":"Fire"}`<commit_msg>change TestDBServer to TestDBHost<commit_after>package bebber

import (
  "strings"
  "testing"
  "encoding/json"
  "gopkg.in/mgo.v2"
  "gopkg.in/mgo.v2/bson"
)

func Test_Search(t *testing.T) {
  doc := bson.M{"Song": bson.M{"RingOf": "Fire"}}
  session, err := mgo.Dial(TestDBHost)
  if err != nil {
    t.Fatal(err.Error())
  }
  defer session.Close()

  db := session.DB(TestDBName)
  defer db.DropDatabase()

  filesColl := db.C("files")
  err = filesColl.Insert(doc)
  if err != nil {
    t.Fatal(err.Error())
  }

  searchStr := `{"Song.RingOf": "Fire"}`
  tmp := Search(searchStr, db)
  result := *tmp

  if len(result) != 1 {
    t.Fatal("Expect len 1 was", len(result))
  }

  JSONBytes, err := json.Marshal(result)
  if err != nil {
    t.Fatal(err.Error())
  }

  expectJSONStr := `{"Song":{"RingOf":"Fire"}`
{'fraction_non_alphanumeric': 0.1935881627620222, 'fraction_numerical': 0.004932182490752158, 'mean_word_length': 3.339572192513369, 'pattern_counts': {'":': 10, '<': 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': '2795381', 'n_tokens_mistral': 690, 'n_tokens_neox': 649, 'n_words': 124}