Skip to content
Snippets Groups Projects
Select Git revision
  • 6a540463535f8f38523e61ad5f9e6e2345921514
  • main default protected
  • development
  • integration
  • v1.1.5
  • v1.1.4
  • v1.1.3
  • v1.1.2
  • v1.1.1
  • v1.1.0
  • v1.0.0
11 results

GetCmixParams.swift

Blame
  • Dariusz Rybicki's avatar
    Dariusz Rybicki authored
    991e3c0f
    History
    GetCmixParams.swift 516 B
    ////////////////////////////////////////////////////////////////////////////////
    // Copyright © 2022 Privategrity Corporation                                   /
    //                                                                             /
    // All rights reserved.                                                        /
    ////////////////////////////////////////////////////////////////////////////////
    
    package restlike
    
    import "testing"
    
    // Full test for all add/get/remove cases
    func TestEndpoints(t *testing.T) {
    	ep := &Endpoints{endpoints: make(map[URI]map[Method]Callback)}
    	cb := func(*Message) *Message {
    		return nil
    	}
    
    	testPath := URI("test/path")
    	testMethod := Get
    	err := ep.Add(testPath, testMethod, cb)
    	if _, ok := ep.endpoints[testPath][testMethod]; err != nil || !ok {
    		t.Errorf("Failed to add endpoint: %+v", err)
    	}
    	err = ep.Add(testPath, testMethod, cb)
    	if _, ok := ep.endpoints[testPath][testMethod]; err == nil || !ok {
    		t.Errorf("Expected failure to add endpoint")
    	}
    
    	resultCb, err := ep.Get(testPath, testMethod)
    	if resultCb == nil || err != nil {
    		t.Errorf("Expected to get endpoint: %+v", err)
    	}
    
    	err = ep.Remove(testPath, testMethod)
    	if _, ok := ep.endpoints[testPath][testMethod]; err != nil || ok {
    		t.Errorf("Failed to remove endpoint: %+v", err)
    	}
    	err = ep.Remove(testPath, testMethod)
    	if _, ok := ep.endpoints[testPath][testMethod]; err == nil || ok {
    		t.Errorf("Expected failure to remove endpoint")
    	}
    
    	resultCb, err = ep.Get(testPath, testMethod)
    	if resultCb != nil || err == nil {
    		t.Errorf("Expected failure to get endpoint: %+v", err)
    	}
    }