<commit_before>// +build linux

package storage

import (
	"io/ioutil"
	"os"
	"testing"
	"math/rand"
	"github.com/golang/glog"
	"github.com/stretchr/testify/assert"
)

func TestWAL(t *testing.T) {
	assert := assert.New(t)

	//Create temp directory
	dir, err := ioutil.TempDir("", "IosWALTests")
	if err != nil {
		glog.Fatal(err)
	}
	defer os.RemoveAll(dir) // clean up

	//create file
  testFile := dir + "/test.temp"
	wal := openWriteAheadFile(testFile, "fsync")
	actualBytes, err := ioutil.ReadFile(testFile)
	assert.Equal(64*1000*1000,len(actualBytes), "File is expected size")

	//verfiy that write ahead logging works
  expectedBytes := make([]byte, 100)
	rand.Read(expectedBytes)
  wal.writeAhead(expectedBytes)
  actualBytes, err = ioutil.ReadFile(testFile)
  assert.Nil(err)
  //assert.Equal(1001,len(actualBytes), "Number of bytes read is not same as bytes written")
  assert.Equal(expectedBytes,actualBytes[len(actualBytes)-100+1:], "Bytes read are not same as written")

}<commit_msg>shifting write ahead test bytes by 1<commit_after>// +build linux

package storage

import (
	"io/ioutil"
	"os"
	"testing"
	"math/rand"
	"github.com/golang/glog"
	"github.com/stretchr/testify/assert"
)

func TestWAL(t *testing.T) {
	assert := assert.New(t)

	//Create temp directory
	dir, err := ioutil.TempDir("", "IosWALTests")
	if err != nil {
		glog.Fatal(err)
	}
	defer os.RemoveAll(dir) // clean up

	//create file
  testFile := dir + "/test.temp"
	wal := openWriteAheadFile(testFile, "fsync")
	actualBytes, err := ioutil.ReadFile(testFile)
	assert.Equal(64*1000*1000,len(actualBytes), "File is expected size")

	//verfiy that write ahead logging works
  expectedBytes := make([]byte, 100)
	rand.Read(expectedBytes)
  wal.writeAhead(expectedBytes)
  actualBytes, err = ioutil.ReadFile(testFile)
  assert.Nil(err)
  //assert.Equal(1001,len(actualBytes), "Number of bytes read is not same as bytes written")
  assert.Equal(expectedBytes,actualBytes[len(actualBytes)-100-1:], "Bytes read are not same as written")

}
{'fraction_non_alphanumeric': 0.14491315136476426, 'fraction_numerical': 0.021339950372208438, 'mean_word_length': 4.631284916201118, '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': '3363975', 'n_tokens_mistral': 773, 'n_tokens_neox': 726, 'n_words': 170}