diff options
| author | Jeff Carr <[email protected]> | 2025-01-09 16:18:06 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-01-09 16:18:06 -0600 |
| commit | 7c10ff958e57d02d13287c4cdbe0aca3781e1600 (patch) | |
| tree | 93d5071eb411b5c01b38b457d0cfd21559d4eaea | |
| parent | b1961c371da567692314f775f9bdcb95837d9278 (diff) | |
test unique insert failure
| -rw-r--r-- | example/main.go | 24 | ||||
| -rw-r--r-- | newsort.go | 15 | ||||
| -rw-r--r-- | sort.go | 4 |
3 files changed, 25 insertions, 18 deletions
diff --git a/example/main.go b/example/main.go index 47dad4f..6222701 100644 --- a/example/main.go +++ b/example/main.go @@ -3,7 +3,11 @@ package main -import "go.wit.com/log" +import ( + "os" + + "go.wit.com/log" +) // sent via -ldflags var VERSION string @@ -17,5 +21,21 @@ var pb *Fruits func main() { pb = NewFruits() - log.Info("did nothing yet", pb) + + fruit := &Fruit{ + Brand: "mom", + City: "New NewYork", + } + if pb.AppendUnique(fruit) { + log.Info("AppendUnique() ok") + } else { + log.Info("AppendUnique() failed") + os.Exit(-1) + } + if pb.AppendUnique(fruit) { + log.Info("AppendUnique() worked but should not have") + os.Exit(-1) + } else { + log.Info("AppendUnique() failed ok") + } } @@ -21,21 +21,8 @@ func (pb *Files) makeNewSortfile(pf *File) error { pf.Base.iterTop(f) pf.Base.iterNext(f) + pf.appendUnique(f) // Append() enforce no unique keys - /* - for _, msg := range pf.MsgNames { - if msg.DoMutex { - for _, key := range msg.Sort { - pf.iterTop(f, key) - pf.iterNext(f, key) - } - } else { - log.Info("Skipping syncLock() for", msg.Name, "DoMutex = false") - } - } - */ - - pf.appendUnique(f, nil, sortmap) // Append() enforce no unique keys return nil // iterSortAll(f, sortmap) @@ -185,9 +185,9 @@ func iterEnd(w io.Writer, names map[string]string) { func iterAppend(w io.Writer, names map[string]string) { } -func (pf *File) appendUnique(w io.Writer, blah *MsgName, names map[string]string) { +func (pf *File) appendUnique(w io.Writer) { var MSG string = pf.Bases.Name - var BASE string = names["Base"] + var BASE string = pf.Base.Name var LOCK string = pf.Bases.Lockname if argv.Mutex { |
