Skip to content
Snippets Groups Projects
Select Git revision
  • aa0ccb8a253386e276cac360426c039460650e04
  • master default protected
  • v1.22.9
  • v1.22.8
  • v1.22.7
  • v1.22.6
  • v1.22.5
  • v1.22.4
  • v1.22.3
  • v1.22.1
  • v1.22.0
  • v1.21.0
  • v1.20.5
  • v1.20.4
  • v1.20.3
  • v1.20.2
  • v1.20.1
  • v1.20.0
  • v1.19.0
  • v1.18.3
  • v1.18.2
  • v1.18.1
22 results

export_test.go

Blame
  • Volker Schukai's avatar
    84732226
    History
    export_test.go 908 B
    // Copyright 2022 schukai GmbH
    // SPDX-License-Identifier: AGPL-3.0
    
    package configuration
    
    import (
    	"io"
    	"strings"
    	"testing"
    )
    
    func TestWrite(t *testing.T) {
    
    	config := ConfigStruct2{
    		A: "AXXX",
    		F: 99,
    	}
    	s := New(config)
    
    	// not implemented , Toml, Properties
    	for _, f := range []Format{Yaml, Json} {
    		w := strings.Builder{}
    		x := io.Writer(&w)
    
    		s.Write(x, f)
    
    		if s.HasErrors() {
    			t.Error(s.Errors())
    			s.ResetErrors()
    			continue
    		}
    
    		if w.String() == "" {
    			t.Error("Expected not empty")
    		}
    
    		content := w.String()
    
    		if f == Yaml {
    
    			if strings.Contains(content, "AXXX") == false {
    				t.Error("Expected AXXX")
    			}
    
    			if strings.Contains(content, "B: false") == false {
    				t.Error("Expected not B: false got ", w.String())
    			}
    
    			if strings.Contains(content, "F: 99") == false {
    				t.Error("Expected not F: 99 got ", w.String())
    			}
    		} else if f == Json {
    
    		}
    	}
    
    }