<commit_before>package oauth2

import (
  "testing"
)

type mockData struct {
}

func TestNewMemoryStore(t *testing.T) {
  m := NewMemoryStore()
  if m == nil {
    t.Error("Fail to create memory store")
  }
  if m.store == nil {
    t.Error("Fail to create map for memory store")
  }
  if m.locker == nil {
    t.Error("Fail to create locker for memory store")
  }
}

func TestMemoryStoreSaveAndRead(t *testing.T) {
  m := NewMemoryStore()
  data := &mockData{}
  id := "id"
  m.Save(id, data)
  rdata := m.Read(id)
  if data != rdata {
    t.Error("Memory store fail to save and read")
  }
}

func TestMemoryStoreRemove(t *testing.T) {
  m := NewMemoryStore()
  data := &mockData{}
  id := "id"
  m.Save(id, data)
  m.Remove(id)
  if m.Read(id) != nil {
    t.Error("Memory store fail to remove data")
  }
}

func TestNewTokenStore(t *testing.T) {
}<commit_msg>Add test for token store<commit_after>package oauth2

import (
  "testing"
)

type mockData struct {
}

func TestNewMemoryStore(t *testing.T) {
  m := NewMemoryStore()
  if m == nil {
    t.Error("Fail to create memory store")
  }
  if m.store == nil {
    t.Error("Fail to create map for memory store")
  }
  if m.locker == nil {
    t.Error("Fail to create locker for memory store")
  }
}

func TestMemoryStoreSaveAndRead(t *testing.T) {
  m := NewMemoryStore()
  data := &mockData{}
  id := "id"
  m.Save(id, data)
  rdata := m.Read(id)
  if data != rdata {
    t.Error("Memory store fail to save and read")
  }
}

func TestMemoryStoreRemove(t *testing.T) {
  m := NewMemoryStore()
  data := &mockData{}
  id := "id"
  m.Save(id, data)
  m.Remove(id)
  if m.Read(id) != nil {
    t.Error("Memory store fail to remove data")
  }
}

func TestNewTokenStore(t *testing.T) {
  m := NewTokenStore()
  if m == nil || m.store == nil {
    t.Error("Fail to create token store")
  }
}

func TestTokenStoreSaveAndRead(t *testing.T) {
  m := NewTokenStore()
  token := NewToken(kClientId, kScope, kBaseUri, kLife)
  id, err := m.Save(token)
  if err != nil {
    t.Error("Fail to save token")
  }
  rtoken, err := m.Read(id)
  if err != nil {
    t.Error("Fail to read token")
  }
  if rtoken != token {
    t.Error("Read wrong token")
  }
}

func TestTokenStoreRemove(t *testing.T) {
  m := NewTokenStore()
  token := NewToken(kClientId, kScope, kBaseUri, kLife)
  id, _ := m.Save(token)
  err := m.Remove(id)
  if err != nil {
    t.Error("Fail to remove token")
  }
  if rtoken, _ := m.Read(id); rtoken != nil {
    t.Error("Fail to remove token but no error reported")
  }
}
{'fraction_non_alphanumeric': 0.15205371248025276, 'fraction_numerical': 0.0007898894154818325, 'mean_word_length': 3.0920840064620356, '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': '4079100', 'n_tokens_mistral': 951, 'n_tokens_neox': 947, 'n_words': 260}