Skip to content

Commit

Permalink
Renamed functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ax4w committed Nov 14, 2023
1 parent 9188768 commit f8a8369
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestBenchmark(t *testing.T) {
return
}
}
gorage := CreateNewGorage("./benchmark", false, false)
gorage := Create("./benchmark", false, false)
randomTable := gorage.CreateTable("Random")
if randomTable == nil {
t.Fatalf("Table was not created")
Expand Down Expand Up @@ -55,7 +55,7 @@ func TestBenchmark(t *testing.T) {

t1 = time.Now().Unix()
gorage.Save()
gorage = OpenGorage("./benchmark")
gorage = Open("./benchmark")
t.Log(fmt.Sprintf("Saving and loading took %ds", time.Now().Unix()-t1))

t1 = time.Now().Unix()
Expand Down
6 changes: 3 additions & 3 deletions gorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (g *Gorage) Save() {
/*
Open a gorage from a path
*/
func OpenGorage(path string) *Gorage {
func Open(path string) *Gorage {
f, err := os.Open(path)
if err != nil {
panic(err.Error())
Expand Down Expand Up @@ -130,7 +130,7 @@ allowDuplicates: If a table can contain multiple identical datasets
log: If you want to get spammed :^)
*/
func CreateNewGorage(path string, allowDuplicates, log bool) *Gorage {
func Create(path string, allowDuplicates, log bool) *Gorage {
if !fileExists(path) {
f, err := os.Create(path)
if err != nil {
Expand All @@ -152,5 +152,5 @@ func CreateNewGorage(path string, allowDuplicates, log bool) *Gorage {
panic(err.Error())
}
}
return OpenGorage(path)
return Open(path)
}
2 changes: 1 addition & 1 deletion gorage_concurrency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestConcurrency(t *testing.T) {
return
}
}
g := CreateNewGorage("./concurrent", false, false)
g := Create("./concurrent", false, false)
//CreateTable should not be used concurrent UNLESS it is waited on properly.
//But it still can fail in concurrent usage. NOT RECOMMENDED
var group sync.WaitGroup
Expand Down
18 changes: 9 additions & 9 deletions gorage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ func TestCreateFile(t *testing.T) {
return
}
}
CreateNewGorage("./test", false, false)
Create("./test", false, false)
_, err := os.Stat("./test")
if os.IsNotExist(err) {
t.Fatalf("File was not created")
}
}

func TestCreateTable(t *testing.T) {
g := OpenGorage("./test")
g := Open("./test")
table := g.CreateTable("User")
if table != nil {
table.AddColumn("FirstName", STRING).
Expand All @@ -36,7 +36,7 @@ func TestCreateTable(t *testing.T) {
}

func TestInsert(t *testing.T) {
g := OpenGorage("./test")
g := Open("./test")
userTable := g.FromTable("User")
userTable.Insert([]interface{}{"James", "aa", 2, 85.5})
userTable.Insert([]interface{}{"Carl", "aa", 3, 90.5})
Expand All @@ -50,7 +50,7 @@ func TestInsert(t *testing.T) {
}

func TestUpdate(t *testing.T) {
g := OpenGorage("./test")
g := Open("./test")
g.FromTable("User").
Where(":FirstName == 'James'").
Update(map[string]interface{}{
Expand All @@ -66,7 +66,7 @@ func TestUpdate(t *testing.T) {
}

func TestWhere(t *testing.T) {
g := OpenGorage("./test")
g := Open("./test")
userTable := g.
FromTable("User").
Where("( :FirstName == 'William' && :Age == 2 ) || :IQ >= 90.0").
Expand Down Expand Up @@ -96,7 +96,7 @@ func TestWhere(t *testing.T) {
}

func TestDelete(t *testing.T) {
g := OpenGorage("./test")
g := Open("./test")
g.
FromTable("User").
Where(":FirstName == 'Carl'").
Expand All @@ -111,13 +111,13 @@ func TestDelete(t *testing.T) {
}

func TestAddColumn(t *testing.T) {
g := OpenGorage("./test")
g := Open("./test")
g.FromTable("User").AddColumn("Lol", INT)
g.Save()
}

func TestRemoveColumn(t *testing.T) {
g := OpenGorage("./test")
g := Open("./test")
table := g.FromTable("User")
l := len(table.Columns)
table.RemoveColumn("IQ")
Expand All @@ -135,7 +135,7 @@ func TestComplete(t *testing.T) {
return
}
}
gorage := CreateNewGorage("./Social", false, false)
gorage := Create("./Social", false, false)
userTable := gorage.CreateTable("User")
if userTable == nil {
return
Expand Down

0 comments on commit f8a8369

Please sign in to comment.