action handling: minor improvements, tests
This commit is contained in:
		
							parent
							
								
									5aa1cc07b6
								
							
						
					
					
						commit
						2908b82f29
					
				
					 2 changed files with 8 additions and 3 deletions
				
			
		| 
						 | 
					@ -70,9 +70,13 @@ func (msg *message) WithPayload(p lib.Payload) lib.Message {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func New(args ...string) lib.Message {
 | 
					func New(args ...string) lib.Message {
 | 
				
			||||||
	args = append(args, "", "")[:4]
 | 
						args = append(args, "", "")[:4]
 | 
				
			||||||
 | 
						domain := args[0]
 | 
				
			||||||
 | 
						if domain == "" {
 | 
				
			||||||
 | 
							domain = "scopes"
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	return &message{
 | 
						return &message{
 | 
				
			||||||
		head: &head{
 | 
							head: &head{
 | 
				
			||||||
			domain: args[0],
 | 
								domain: domain,
 | 
				
			||||||
			action: args[1],
 | 
								action: args[1],
 | 
				
			||||||
			class:  args[2],
 | 
								class:  args[2],
 | 
				
			||||||
			item:   args[3],
 | 
								item:   args[3],
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -69,9 +69,10 @@ func ActionTest(t *testing.T) {
 | 
				
			||||||
		return true
 | 
							return true
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	cfg := config.Base("testing", nil).
 | 
						cfg := config.Base("testing", nil).
 | 
				
			||||||
		AddAction("doit", action.Base(hdlr))
 | 
							AddAction("scopes|doit|task", action.Base(hdlr))
 | 
				
			||||||
	ctx := context.AppContext(cfg)
 | 
						ctx := context.AppContext(cfg)
 | 
				
			||||||
	msg := message.SimpleMessage("doit")
 | 
						//msg := message.SimpleMessage("doit")
 | 
				
			||||||
 | 
						msg := message.New("", "doit", "task", "4711")
 | 
				
			||||||
	lib.HandleMsg(ctx, msg)
 | 
						lib.HandleMsg(ctx, msg)
 | 
				
			||||||
	t.AssertEqual(result.data, "done")
 | 
						t.AssertEqual(result.data, "done")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue