cmd/schemagen: refactoring

- Replace log.Faltal with error wrapping in schemagen func
- Simplify tests, use temp dir and ioutil functions, remove boilerplate code
- In test use schemagen keyspace to avoid name conflict with examples
- Change template
This commit is contained in:
Michał Matczuk
2021-11-17 11:49:42 +01:00
committed by Michal Jan Matczuk
parent 39bf42f122
commit 8477485a45
7 changed files with 239 additions and 288 deletions

View File

@@ -1,42 +1,43 @@
// Code generated by "gocqlx/cmd/schemagen"; DO NOT EDIT.
package {{pkgname}}
package foobar
import "github.com/scylladb/gocqlx/v2/table"
var PlaylistsMetadata = table.Metadata{
Name: "playlists",
Columns: []string{
"album",
"artist",
"id",
"song_id",
"title",
},
PartKey: []string{
"id",
},
SortKey: []string{
"title",
"album",
"artist",
},
}
var PlaylistsTable = table.New(PlaylistsMetadata)
// Table models.
var (
Playlists = table.New(table.Metadata{
Name: "playlists",
Columns: []string{
"album",
"artist",
"id",
"song_id",
"title",
},
PartKey: []string{
"id",
},
SortKey: []string{
"title",
"album",
"artist",
},
})
var SongsMetadata = table.Metadata{
Name: "songs",
Columns: []string{
"album",
"artist",
"data",
"id",
"tags",
"title",
},
PartKey: []string{
"id",
},
SortKey: []string{},
}
var SongsTable = table.New(SongsMetadata)
Songs = table.New(table.Metadata{
Name: "songs",
Columns: []string{
"album",
"artist",
"data",
"id",
"tags",
"title",
},
PartKey: []string{
"id",
},
SortKey: []string{},
})
)