/* NAME meta_test.go DESCRIPTION See Readme.md AUTHOR Saxon Nelson-Milton LICENSE meta_test.go is Copyright (C) 2017-2019 the Australian Ocean Lab (AusOcean) It is free software: you can redistribute it and/or modify them under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with revid in gpl.txt. If not, see http://www.gnu.org/licenses. */ package mts import ( "testing" ) // TODO: test add when key doesn't exist func TestAddAndGet(t *testing.T) { meta := NewMeta() meta.Add("loc", "a,b,c") meta.Add("ts", "12345678") if data, err := meta.Get("loc"); err != nil { t.Errorf("Could not get data for key: loc: %v", err.Error()) if data != "a,b,c" { t.Errorf("Did not get expected data") } } if data, err := meta.Get("ts"); err != nil { t.Errorf("Could not get data for key: ts: %v", err.Error()) if data != "12345678" { t.Errorf("Did not get expected data") } } } // TODO: test add when key does exist func TestUpdate(t *testing.T) { meta := NewMeta() meta.Add("loc", "a,b,c") meta.Add("loc", "d,e,f") if data, err := meta.Get("loc"); err != nil { t.Errorf("Did not expect err: %v", err.Error()) if data != "d,e,f" { t.Errorf("Data did not correctly update for key \"loc\"") } } } // TODO: test all // TODO: test get when key exists // TODO: test get when key doesn't exist // TODO: test delete when key exists // TODO: test delete when key doesn't exist